Struct lasso::RodeoResolver
source · pub struct RodeoResolver<K = Spur> { /* private fields */ }
Expand description
A read-only view of a Rodeo
or ThreadedRodeo
that allows contention-free access to interned strings
with only key to string resolution
The key type is the same as the Rodeo
or ThreadedRodeo
that created it
Implementations§
source§impl<K> RodeoResolver<K>
impl<K> RodeoResolver<K>
sourcepub fn resolve<'a>(&'a self, key: &K) -> &'a strwhere
K: Key,
pub fn resolve<'a>(&'a self, key: &K) -> &'a strwhere
K: Key,
Resolves a string by its key. Only keys made by the current Resolver or the creator of the current Resolver may be used
Panics
Panics if the key is out of bounds
Example
use lasso::Rodeo;
// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");
let rodeo = rodeo.into_resolver();
assert_eq!("Strings of things with wings and dings", rodeo.resolve(&key));
sourcepub fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>where
K: Key,
pub fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>where
K: Key,
Resolves a string by its key, returning None
if the key is out of bounds. Only keys
made by the current Resolver or the creator of the current Resolver may be used
Example
use lasso::Rodeo;
// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");
let rodeo = rodeo.into_resolver();
assert_eq!(Some("Strings of things with wings and dings"), rodeo.try_resolve(&key));
sourcepub unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a strwhere
K: Key,
pub unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a strwhere
K: Key,
Resolves a string by its key without preforming bounds checks
Safety
The key must be valid for the current interner
Example
use lasso::Rodeo;
// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");
let rodeo = rodeo.into_resolver();
unsafe {
assert_eq!("Strings of things with wings and dings", rodeo.resolve_unchecked(&key));
}
sourcepub fn contains_key(&self, key: &K) -> boolwhere
K: Key,
pub fn contains_key(&self, key: &K) -> boolwhere
K: Key,
Returns true
if the given key exists in the current interner
Example
use lasso::Rodeo;
let mut rodeo = Rodeo::default();
let key = rodeo.get_or_intern("Strings of things with wings and dings");
let rodeo = rodeo.into_resolver();
assert!(rodeo.contains_key(&key));
assert!(!rodeo.contains_key(&key_that_doesnt_exist));
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Gets the number of interned strings
Example
use lasso::Rodeo;
// ThreadedRodeo is interchangeable for Rodeo here
let mut rodeo = Rodeo::default();
rodeo.get_or_intern("Documentation often has little hidden bits in it");
let rodeo = rodeo.into_resolver();
assert_eq!(rodeo.len(), 1);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if there are no currently interned strings
Example
use lasso::Rodeo;
// ThreadedRodeo is interchangeable for Rodeo here
let rodeo = Rodeo::default();
let rodeo = rodeo.into_resolver();
assert!(rodeo.is_empty());
Trait Implementations§
source§impl<K: Debug> Debug for RodeoResolver<K>
impl<K: Debug> Debug for RodeoResolver<K>
source§impl<K: Key> Index<K> for RodeoResolver<K>
impl<K: Key> Index<K> for RodeoResolver<K>
source§impl<'a, K: Key> IntoIterator for &'a RodeoResolver<K>
impl<'a, K: Key> IntoIterator for &'a RodeoResolver<K>
source§impl<K, S> PartialEq<Rodeo<K, S>> for RodeoResolver<K>
impl<K, S> PartialEq<Rodeo<K, S>> for RodeoResolver<K>
source§impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoResolver<K>
impl<K, S> PartialEq<RodeoReader<K, S>> for RodeoResolver<K>
source§fn eq(&self, other: &RodeoReader<K, S>) -> bool
fn eq(&self, other: &RodeoReader<K, S>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<K, S> PartialEq<RodeoResolver<K>> for Rodeo<K, S>
impl<K, S> PartialEq<RodeoResolver<K>> for Rodeo<K, S>
source§fn eq(&self, other: &RodeoResolver<K>) -> bool
fn eq(&self, other: &RodeoResolver<K>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<K, S> PartialEq<RodeoResolver<K>> for RodeoReader<K, S>
impl<K, S> PartialEq<RodeoResolver<K>> for RodeoReader<K, S>
source§fn eq(&self, other: &RodeoResolver<K>) -> bool
fn eq(&self, other: &RodeoResolver<K>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<K> PartialEq<RodeoResolver<K>> for RodeoResolver<K>
impl<K> PartialEq<RodeoResolver<K>> for RodeoResolver<K>
source§impl<K, S> PartialEq<RodeoResolver<K>> for ThreadedRodeo<K, S>where
K: Eq + Hash + Key,
S: Clone + BuildHasher,
impl<K, S> PartialEq<RodeoResolver<K>> for ThreadedRodeo<K, S>where
K: Eq + Hash + Key,
S: Clone + BuildHasher,
source§fn eq(&self, other: &RodeoResolver<K>) -> bool
fn eq(&self, other: &RodeoResolver<K>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<K> Resolver<K> for RodeoResolver<K>where
K: Key,
impl<K> Resolver<K> for RodeoResolver<K>where
K: Key,
source§fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>
fn try_resolve<'a>(&'a self, key: &K) -> Option<&'a str>
None
if it cannot be foundsource§unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str
unsafe fn resolve_unchecked<'a>(&'a self, key: &K) -> &'a str
source§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
true
if the current interner contains the given key