Skip to content

Commit

Permalink
Remove unused utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Nov 3, 2022
1 parent e35b12c commit 3cd111b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
25 changes: 0 additions & 25 deletions src/intermediate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ impl<'a> IntermediateTypes<'a> {
}
}

pub fn has_ident(&self, ident: &RustIdent) -> bool {
let foo: Vec<RustIdent> = self.type_aliases.keys().fold(vec![], |mut acc, alias| {
match alias {
AliasIdent::Reserved(_) => {},
AliasIdent::Rust(ident) => { acc.push(ident.clone()) }
};
acc
});
println!("{:?}", self.plain_groups.keys().chain(foo.iter()).chain(self.rust_structs.keys()).chain(self.generic_defs.keys()).chain(self.generic_instances.keys()));
self.plain_groups.contains_key(ident)
|| self.type_aliases.contains_key(&AliasIdent::Rust(ident.clone()))
|| self.rust_structs.contains_key(ident)
|| self.generic_defs.contains_key(ident)
|| self.generic_instances.contains_key(ident)
}

pub fn type_aliases(&self) -> &BTreeMap<AliasIdent, (RustType, bool, bool)> {
&self.type_aliases
}
Expand Down Expand Up @@ -1755,12 +1739,3 @@ impl GenericInstance {
orig.clone()
}
}

fn try_ident_with_id(intermediate_types: &IntermediateTypes, name: &CDDLIdent, value: u32) -> CDDLIdent {
let new_ident = CDDLIdent::new(format!("{}{}", name, value));
let rust_ident = RustIdent::new(new_ident.clone());
match intermediate_types.has_ident(&rust_ident) {
false => new_ident,
true => try_ident_with_id(intermediate_types, name, value + 1)
}
}
11 changes: 0 additions & 11 deletions src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,14 +1131,3 @@ fn _has_embed<'a, 'b>(parent_visitor: &'a ParentVisitor, cddl_type: &CDDLType<'a
_ => false
}
}

/// A recursive type is defied as one that has a node of the same type in its parent hierarchy
fn is_recursive<'a, 'b>(parent_visitor: &'a ParentVisitor, cddl_type: &CDDLType<'a, 'b>) -> bool {
_is_recursive(parent_visitor, &mut HashSet::new(), cddl_type)
}
fn _is_recursive<'a, 'b>(parent_visitor: &'a ParentVisitor, seen_set: &mut HashSet<Discriminant<CDDLType<'a, 'b>>>, cddl_type: &CDDLType<'a, 'b>) -> bool {
match seen_set.insert(std::mem::discriminant(cddl_type)) {
true => _is_recursive(parent_visitor, seen_set, cddl_type.parent(parent_visitor).unwrap()),
false => false
}
}

0 comments on commit 3cd111b

Please sign in to comment.