Struct intern_arc::InternOrd [−][src]
Implementations
impl<T: ?Sized + Ord> InternOrd<T>
[src]
Interner for values with a total order
The interner is cheaply cloneable by virtue of keeping the underlying storage
in an Arc
. Once the last
reference to this interner is dropped, it will clear its backing storage and
release all references to the interned values it has created that are still live.
Those values remain fully operational until dropped. Memory for the values
themselves is freed for each value individually once its last reference is dropped.
pub fn new() -> Self
[src]
pub fn len(&self) -> usize
[src]
Returns the number of objects currently kept in this interner.
pub fn is_empty(&self) -> bool
[src]
Returns true
when this interner doesn’t hold any values.
pub fn intern_ref(&self, value: &T) -> Interned<T> where
T: ToOwned,
T::Owned: Into<Box<T>>,
[src]
T: ToOwned,
T::Owned: Into<Box<T>>,
Intern a value from a shared reference by allocating new memory for it.
use intern_arc::{InternOrd, Interned}; let strings = InternOrd::<str>::new(); let i: Interned<str> = strings.intern_ref("hello world!");
pub fn intern_box(&self, value: Box<T>) -> Interned<T>
[src]
Intern a value from an owned reference without allocating new memory for it.
use intern_arc::{InternOrd, Interned}; let strings = InternOrd::<str>::new(); let hello: Box<str> = "hello world!".into(); let i: Interned<str> = strings.intern_box(hello);
(This also works nicely with a String
that can be turned .into()
a Box
.)
pub fn intern_sized(&self, value: T) -> Interned<T> where
T: Sized,
[src]
T: Sized,
Intern a sized value, allocating heap memory for it.
use intern_arc::{InternOrd, Interned}; let arrays = InternOrd::<[u8; 1000]>::new(); let i: Interned<[u8; 1000]> = arrays.intern_sized([0; 1000]);
Trait Implementations
impl<T: ?Sized> Clone for InternOrd<T>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: ?Sized + Ord> Default for InternOrd<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for InternOrd<T>
impl<T: ?Sized> Send for InternOrd<T> where
T: Send + Sync,
T: Send + Sync,
impl<T: ?Sized> Sync for InternOrd<T> where
T: Send + Sync,
T: Send + Sync,
impl<T: ?Sized> Unpin for InternOrd<T>
impl<T> !UnwindSafe for InternOrd<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,