[][src]Struct lasso::ResolverLasso

pub struct ResolverLasso<K: Key = Cord> { /* fields omitted */ }

A read-only view of a Lasso that allows contention-free access to interned strings, but only for key -> str resolution

Made with the Lasso::into_resolver or ReadOnlyLasso::into_resolver methods, the key type defaults to the ones used by the Lasso that created it

Methods

impl<K: Key> ResolverLasso<K>[src]

pub fn resolve<'a>(&'a self, key: &K) -> &'a str[src]

Resolves a string by its key

Safety

Safety relies on the given Key's adherence to symmetry, if the key gives bad indexes then it will cause UB, With that in mind, never use any key not directly provided by the interner

Example

use lasso::{Cord, Key, Lasso};

let lasso = Lasso::default();
let key = lasso.intern("Strings of things with wings and dings");

let lasso = lasso.into_resolver();
assert_eq!("Strings of things with wings and dings", lasso.resolve(&key));

pub fn len(&self) -> usize[src]

Gets the number of interned strings

Example

use lasso::Lasso;

let lasso = Lasso::default();
lasso.intern("Documentation often has little hidden bits in it");

let lasso = lasso.into_resolver();
assert_eq!(lasso.len(), 1);

pub fn is_empty(&self) -> bool[src]

Returns true if there are no currently interned strings

Example

use lasso::Lasso;

let lasso = Lasso::default();

let lasso = lasso.into_resolver();
assert!(lasso.is_empty());

Trait Implementations

impl<K: Key> Clone for ResolverLasso<K>[src]

impl<K: Debug + Key> Debug for ResolverLasso<K>[src]

impl<K: Key> Drop for ResolverLasso<K>[src]

Deallocate the leaked strings interned by ResolverLasso

impl<K: Key> Send for ResolverLasso<K>[src]

impl<K: Key> Sync for ResolverLasso<K>[src]

Auto Trait Implementations

impl<K> RefUnwindSafe for ResolverLasso<K> where
    K: RefUnwindSafe

impl<K> Unpin for ResolverLasso<K> where
    K: Unpin

impl<K> UnwindSafe for ResolverLasso<K> where
    K: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.