fn generate_type(&mut self, ty: &Type) -> WeldResult<String> {
        use crate::ast::Type::*;
        if let Some(name) = self.generated_types.get(ty) {
            return Ok(name.to_string());
        }

        let result = match *ty {
            Scalar(ref kind) => Ok(format!("{}", kind)),
            Vector(ref elem) => Ok(format!("vec<{}>", self.generate_type(elem)?)),
            Struct(ref elems) => self.generate_struct_definition(elems),
            // Other types (Builders, Functions, etc.) cannot be passed into Weld.
            _ => weld_err!("Invalid C++ type {:?}", ty),
        };

        if result.is_ok() {
            self.generated_types
                .insert(ty.clone(), result.as_ref().unwrap().clone());
        }
        self.code.add("\n");

        result
    }
Generates a single type in returns its name.
weld-hdrgen/src/main.rs