/// Print an enum that allows selection between two different types (ie, what is
/// a range union in rdf)
Print an enum that allows selection between two different types
Print an enum that allows selection between two different types
fn print_range_union(out: &mut StringWriter, lookup: &HashMap<String, SchemaUnion>, range_union: &RangeUnion) {
    let types_array = range_union.types.iter().map(|x| RangeUnion::type_to_name(x)).collect::<Vec<_>>();
    let generics = range_union.types.iter()
        .map(|ty| ty.vf_struct(lookup))
        .filter(|x| x.is_some())
        .map(|ty| format!("{}", ty.unwrap().name.to_camel_case().to_uppercase()))
        .collect::<Vec<_>>();
    out.line(format!("/// An enum that allows a type union for ({})", types_array.join(", ")));
    out.line("#[derive(Debug, PartialEq, Clone)]");
    out.line(r#"#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]"#);
    if generics.len() > 0 {
        out.line(format!("pub enum {}<{}> {{", range_union.name(), generics.join(", ")));
    } else {
        out.line(format!("pub enum {} {{", range_union.name()));
    }
    out.inc_indent();
    for ty in &range_union.types {
        let name = RangeUnion::type_to_name(ty);
        let typestring = if let Some(class) = ty.vf_struct(lookup) {
            format!("{}", class.name.to_camel_case().to_uppercase())
        } else {
            name.clone()
        };
        out.line(format!("{}({}),", name, typestring));
    }
    out.dec_indent();
    out.line("}");
}
fn print_range_union ( out : & mut StringWriter , lookup : & HashMap < String , SchemaUnion > , range_union : & RangeUnion ) { let types_array = range_union . types . iter ( ) . map ( | x | RangeUnion :: type_to_name ( x ) ) . collect :: < Vec < _ > > ( ) ; let generics = range_union . types . iter ( ) . map ( | ty | ty . vf_struct ( lookup ) ) . filter ( | x | x . is_some ( ) ) . map ( | ty | format ! ( " " ty unwrap ( ) name to_camel_case ( ) to_uppercase ( ) ) ) . collect :: < Vec < _ > > ( ) ; out . line ( format ! ( " " types_array join ( " " ) ) ) ; out . line ( " " ) ; out . line ( r#"#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]"# ) ; if generics . len ( ) > 0 { out . line ( format ! ( " " range_union name ( ) generics join ( " " ) ) ) ; } else { out . line ( format ! ( " " range_union name ( ) ) ) ; } out . inc_indent ( ) ; for ty in & range_union . types { let name = RangeUnion :: type_to_name ( ty ) ; let typestring = if let Some ( class ) = ty . vf_struct ( lookup ) { format ! ( " " class name to_camel_case ( ) to_uppercase ( ) ) } else { name . clone ( ) } ; out . line ( format ! ( " " name typestring ) ) ; } out . dec_indent ( ) ; out . line ( " " ) ; }
Print an enum that allows selection between two different types (ie, what is
a range union in rdf)
Print an enum that allows selection between two different types ( ie what is a range union in rdf )
out
&mut StringWriter
lookup
&HashMap<String, SchemaUnion>
range_union
&RangeUnion