in serde-generate/src/rust.rs [218:261]
fn quote_type(format: &Format, known_sizes: Option<&HashSet<&str>>) -> String {
use Format::*;
match format {
TypeName(x) => {
if let Some(set) = known_sizes {
if !set.contains(x.as_str()) {
return format!("Box<{}>", x);
}
}
x.to_string()
}
Unit => "()".into(),
Bool => "bool".into(),
I8 => "i8".into(),
I16 => "i16".into(),
I32 => "i32".into(),
I64 => "i64".into(),
I128 => "i128".into(),
U8 => "u8".into(),
U16 => "u16".into(),
U32 => "u32".into(),
U64 => "u64".into(),
U128 => "u128".into(),
F32 => "f32".into(),
F64 => "f64".into(),
Char => "char".into(),
Str => "String".into(),
Bytes => "Bytes".into(),
Option(format) => format!("Option<{}>", Self::quote_type(format, known_sizes)),
Seq(format) => format!("Vec<{}>", Self::quote_type(format, None)),
Map { key, value } => format!(
"Map<{}, {}>",
Self::quote_type(key, None),
Self::quote_type(value, None)
),
Tuple(formats) => format!("({})", Self::quote_types(formats, known_sizes)),
TupleArray { content, size } => {
format!("[{}; {}]", Self::quote_type(content, known_sizes), *size)
}
Variable(_) => panic!("unexpected value"),
}
}