Skip to content

Commit

Permalink
fix docstring and add assert
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Jul 30, 2024
1 parent 8f037b9 commit 97635ae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,20 @@ impl EGraph {
egraph
}

/**
* Gets the serialized class ID for a value.
*/
/// Gets the serialized class ID for a value.
pub fn value_to_class_id(&self, value: &Value) -> egraph_serialize::ClassId {
// Canonicalize the value first so that we always use the canonical e-class ID
let sort = self.get_sort_from_value(value).unwrap();
let mut value = *value;
sort.canonicalize(&mut value, &self.unionfind);
assert!(
!value.tag.to_string().contains('-'),
"Tag cannot contain '-' when serializing"
);
format!("{}-{}", value.tag, value.bits).into()
}

/**
* Gets the value for a serialized class ID.
*/
/// Gets the value for a serialized class ID.
pub fn class_id_to_value(&self, eclass_id: &egraph_serialize::ClassId) -> Value {
let s = eclass_id.to_string();
let (tag, bits) = s.split_once('-').unwrap();
Expand Down

0 comments on commit 97635ae

Please sign in to comment.