Struct yash_syntax::alias::HashEntry
source · pub struct HashEntry(pub Rc<Alias>);
Expand description
Wrapper of Alias
for inserting into a hash set.
A HashEntry
wraps an Alias
in Rc
so that the alias definition can be referred to even
after the definition is removed. The Hash
and PartialEq
implementation for HashEntry
compares only names.
let mut entries = std::collections::HashSet::new();
let name = "foo";
let origin = yash_syntax::source::Location::dummy("");
let old = yash_syntax::alias::HashEntry::new(
name.to_string(), "old".to_string(), false, origin.clone());
let new = yash_syntax::alias::HashEntry::new(
name.to_string(), "new".to_string(), false, origin);
entries.insert(old);
let old = entries.replace(new).unwrap();
assert_eq!(old.0.replacement, "old");
assert_eq!(entries.get(name).unwrap().0.replacement, "new");
Tuple Fields§
§0: Rc<Alias>
Implementations§
Trait Implementations§
source§impl PartialEq for HashEntry
impl PartialEq for HashEntry
impl Eq for HashEntry
impl StructuralEq for HashEntry
Auto Trait Implementations§
impl !RefUnwindSafe for HashEntry
impl !Send for HashEntry
impl !Sync for HashEntry
impl Unpin for HashEntry
impl !UnwindSafe for HashEntry
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more