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§

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

Returns an iterator over the interned strings

Trait Implementations§

Formats the value using the given formatter. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Resolves the given key into a string Read more
Attempts to resolve the given key into a string, returning None if it cannot be found
Resolves a string by its key without preforming bounds checks Read more
Returns true if the current interner contains the given key
Gets the number of currently interned strings
Returns true if there are no currently interned strings

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.