fn generate_sequence(&mut self, name: &str, components: &ComponentTypeList) -> Result<String> {
        let mut generated_struct = Struct::new(name);

        for field in components.components.as_ref().unwrap() {
            // Unwrap currently needed as i haven't created the simplified AST without
            // `ComponentsOf` yet.
            let (ty, optional, default) = field.as_type().unwrap();
            let field = FieldBuilder::new(ty.name.as_ref().unwrap().to_snake_case(), self.generate_type(&ty)?)
                .optional(*optional)
                .default_value(default.clone().and_then(|v| self.generate_value(&v).ok()))
                .build();

            generated_struct.add_field(field);
        }

        self.structs.push(generated_struct);

        Ok(name.to_camel_case())
    }
/// As Rust doesn't allow you to have anonymous structs,
/// `generate_sequence` returns the name of the struct and
/// stores the definition seperately.
As Rust doesn't allow you to have anonymous structs,
`generate_sequence` returns the name of the struct and
stores the definition seperately.
As Rust doesn ' t allow you to have anonymous structs ` generate_sequence ` returns the name of the struct and stores the definition seperately .
fn generate_sequence(&mut self, name: &str, components: &ComponentTypeList) -> Result<String> {
        let mut generated_struct = Struct::new(name);
        for field in components.components.as_ref().unwrap() {
            // Unwrap currently needed as i haven't created the simplified AST without
            // `ComponentsOf` yet.
            let (ty, optional, default) = field.as_type().unwrap();
            let field = FieldBuilder::new(ty.name.as_ref().unwrap().to_snake_case(), self.generate_type(&ty)?)
                .optional(*optional)
                .default_value(default.clone().and_then(|v| self.generate_value(&v).ok()))
                .build();
            generated_struct.add_field(field);
        }
        self.structs.push(generated_struct);
        Ok(name.to_camel_case())
    }
fn generate_sequence ( & mut self , name : & str , components : & ComponentTypeList ) -> Result < String > { let mut generated_struct = Struct :: new ( name ) ; for field in components . components . as_ref ( ) . unwrap ( ) { // Unwrap currently needed as i haven't created the simplified AST without // `ComponentsOf` yet. let ( ty , optional , default ) = field . as_type ( ) . unwrap ( ) ; let field = FieldBuilder :: new ( ty . name . as_ref ( ) . unwrap ( ) . to_snake_case ( ) , self . generate_type ( & ty ) ? ) . optional ( * optional ) . default_value ( default . clone ( ) . and_then ( | v | self . generate_value ( & v ) . ok ( ) ) ) . build ( ) ; generated_struct . add_field ( field ) ; } self . structs . push ( generated_struct ) ; Ok ( name . to_camel_case ( ) ) }
As Rust doesn't allow you to have anonymous structs,
`generate_sequence` returns the name of the struct and
stores the definition seperately.
As Rust doesn ' t allow you to have anonymous structs ` generate_sequence ` returns the name of the struct and stores the definition seperately .
&mut self
name
&str
components
&ComponentTypeList
&mut self
name
&str
components
&ComponentTypeList