pub struct DroplessInternSet<S = BuildHasherDefault<FxHasher>> { /* private fields */ }Expand description
A dropless interner.
Interning on this type always copies the given value into internal buffer.
Implementations§
Source§impl DroplessInternSet
impl DroplessInternSet
pub fn new() -> DroplessInternSet
Source§impl<S> DroplessInternSet<S>where
S: BuildHasher,
impl<S> DroplessInternSet<S>where
S: BuildHasher,
pub fn with_hasher(hash_builder: S) -> DroplessInternSet<S>
pub fn intern<K>(&mut self, value: &K) -> Interned<'_, K>
pub fn intern_formatted_str<K>( &mut self, value: &K, upper_size: usize, ) -> Result<Interned<'_, str>, Error>
Sourcepub fn get<K>(&self, value: &K) -> Option<Interned<'_, K>>
pub fn get<K>(&self, value: &K) -> Option<Interned<'_, K>>
§Eaxmples
use any_intern::DroplessInternSet;
use std::hash::RandomState;
let mut set = DroplessInternSet::with_hasher(RandomState::new());
set.intern("hello");
assert_eq!(set.get("hello").as_deref(), Some("hello"));
assert!(set.get("hi").is_none());pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
Trait Implementations§
Source§impl<S> Debug for DroplessInternSet<S>where
S: Debug,
impl<S> Debug for DroplessInternSet<S>where
S: Debug,
Source§impl<S> Default for DroplessInternSet<S>where
S: Default,
impl<S> Default for DroplessInternSet<S>where
S: Default,
Source§fn default() -> DroplessInternSet<S>
fn default() -> DroplessInternSet<S>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<S = BuildHasherDefault<FxHasher>> !Freeze for DroplessInternSet<S>
impl<S = BuildHasherDefault<FxHasher>> !RefUnwindSafe for DroplessInternSet<S>
impl<S = BuildHasherDefault<FxHasher>> !Send for DroplessInternSet<S>
impl<S = BuildHasherDefault<FxHasher>> !Sync for DroplessInternSet<S>
impl<S> Unpin for DroplessInternSet<S>where
S: Unpin,
impl<S = BuildHasherDefault<FxHasher>> !UnwindSafe for DroplessInternSet<S>
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