pub struct InternedStr<'a> { /* private fields */ }Expand description
An interned string.
Implements Eq, Ord and Hash. Note that
comparison and hashing is done on the internal pointer value, not the actual
string value. This means that:
- It does not make sense to compare
InternedStrvalues from differentStrInternerinstances, Ordshould not be relied to be deterministic.
let arena = rsjsonnet_lang::arena::Arena::new();
let interner = rsjsonnet_lang::interner::StrInterner::new();
let a1 = interner.intern(&arena, "a");
let b1 = interner.intern(&arena, "b");
let a2 = interner.intern(&arena, "a");
let b2 = interner.intern(&arena, "b");
// Of course, they are equal.
assert_eq!(a1, a2);
// "a" and "b" are not equal, but there is no guarantee on the exact ordering.
let cmp1 = a1.cmp(&b1);
assert_ne!(cmp1, std::cmp::Ordering::Equal);
// But the ordering is consistent because they came from the same interner.
let cmp2 = a2.cmp(&b2);
assert_eq!(cmp1, cmp2);Implementations§
Trait Implementations§
Source§impl<'a> Clone for InternedStr<'a>
impl<'a> Clone for InternedStr<'a>
Source§fn clone(&self) -> InternedStr<'a>
fn clone(&self) -> InternedStr<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InternedStr<'_>
impl Debug for InternedStr<'_>
Source§impl<'a> Hash for InternedStr<'a>
impl<'a> Hash for InternedStr<'a>
Source§impl<'a> Ord for InternedStr<'a>
impl<'a> Ord for InternedStr<'a>
Source§fn cmp(&self, other: &InternedStr<'a>) -> Ordering
fn cmp(&self, other: &InternedStr<'a>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialEq for InternedStr<'a>
impl<'a> PartialEq for InternedStr<'a>
Source§impl<'a> PartialOrd for InternedStr<'a>
impl<'a> PartialOrd for InternedStr<'a>
impl<'a> Copy for InternedStr<'a>
impl<'a> Eq for InternedStr<'a>
impl<'a> StructuralPartialEq for InternedStr<'a>
Auto Trait Implementations§
impl<'a> Freeze for InternedStr<'a>
impl<'a> RefUnwindSafe for InternedStr<'a>
impl<'a> Send for InternedStr<'a>
impl<'a> Sync for InternedStr<'a>
impl<'a> Unpin for InternedStr<'a>
impl<'a> UnwindSafe for InternedStr<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.