Struct lasso::RodeoResolver [−][src]
pub struct RodeoResolver<K = Spur> { /* fields omitted */ }
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
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));
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));
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));
}
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));
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);
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());
Returns an iterator over the interned strings and their key values
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more