pub fn parse_entities(s: &str) -> Result<Vec<Entity>, ()> {
    if let Ok(set) = serde_json::from_str::<EntitySet>(s) {
        Ok(set.into())
    } else if let Ok(map) = serde_json::from_str::<HashMap<String, EntitySet>>(s) {
        let mut entities = vec![];
        for (_, set) in map {
            let tmp: Vec<Entity> = set.into();
            entities.extend(tmp);
        }
        Ok(entities)
    } else {
        panic!("invalid Orcbrew") // TODO
    }
}
/// Intelligently parse entities from a string.
Intelligently parse entities from a string.
Intelligently parse entities from a string .
pub fn parse_entities(s: &str) -> Result<Vec<Entity>, ()> {
    if let Ok(set) = serde_json::from_str::<EntitySet>(s) {
        Ok(set.into())
    } else if let Ok(map) = serde_json::from_str::<HashMap<String, EntitySet>>(s) {
        let mut entities = vec![];
        for (_, set) in map {
            let tmp: Vec<Entity> = set.into();
            entities.extend(tmp);
        }
        Ok(entities)
    } else {
        panic!("invalid Orcbrew") // TODO
    }
}
pub fn parse_entities ( s : & str ) -> Result < Vec < Entity > , ( ) > { if let Ok ( set ) = serde_json :: from_str :: < EntitySet > ( s ) { Ok ( set . into ( ) ) } else if let Ok ( map ) = serde_json :: from_str :: < HashMap < String , EntitySet > > ( s ) { let mut entities = vec ! [ ] ; for ( _ , set ) in map { let tmp : Vec < Entity > = set . into ( ) ; entities . extend ( tmp ) ; } Ok ( entities ) } else { panic ! ( " " ) // TODO } }
Intelligently parse entities from a string.
Intelligently parse entities from a string .
s
&str
s
&str