[−][src]Struct arc_interner::ArcIntern
A pointer to a reference-counted interned object.
The interned object will be held in memory only until its reference count reaches zero.
Example
use arc_interner::ArcIntern; let x = ArcIntern::new("hello"); let y = ArcIntern::new("world"); assert_ne!(x, y); assert_eq!(x, ArcIntern::new("hello")); assert_eq!(*x, "hello"); // dereference an ArcIntern like a pointer
Implementations
impl<T: Eq + Hash + Send + Sync + 'static> ArcIntern<T>
[src]
pub fn new(val: T) -> ArcIntern<T>
[src]
Intern a value. If this value has not previously been
interned, then new
will allocate a spot for the value on the
heap. Otherwise, it will return a pointer to the object
previously allocated.
Note that ArcIntern::new
is a bit slow, since it needs to check
a DashMap
which contains its own mutexes.
pub fn num_objects_interned() -> usize
[src]
See how many objects have been interned. This may be helpful in analyzing memory use.
pub fn refcount(&self) -> usize
[src]
Return the number of references for this value.
Trait Implementations
impl<T: Send + Sync + Hash + Eq> AsRef<T> for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync> Borrow<T> for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync + 'static> Clone for ArcIntern<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug + Eq + Hash + Send + Sync + 'static> Debug for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync + Default + 'static> Default for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync> Deref for ArcIntern<T>
[src]
impl<'de, T: Eq + Hash + Send + Sync + 'static + Deserialize<'de>> Deserialize<'de> for ArcIntern<T>
[src]
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
[src]
impl<T: Eq + Hash + Send + Sync + Display> Display for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync> Drop for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync> Eq for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync + 'static> From<T> for ArcIntern<T>
[src]
impl<T: Eq + Hash + Send + Sync> Hash for ArcIntern<T>
[src]
The hash implementation returns the hash of the pointer value, not the hash of the value pointed to. This should be irrelevant, since there is a unique pointer for every value, but it is observable, since you could compare the hash of the pointer with hash of the data itself.
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Eq + Hash + Send + Sync + Ord> Ord for ArcIntern<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: Eq + Hash + Send + Sync> PartialEq<ArcIntern<T>> for ArcIntern<T>
[src]
Efficiently compares two interned values by comparing their pointers.
fn eq(&self, other: &ArcIntern<T>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: Eq + Hash + Send + Sync + PartialOrd> PartialOrd<ArcIntern<T>> for ArcIntern<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<T: Eq + Hash + Send + Sync + Serialize> Serialize for ArcIntern<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for ArcIntern<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for ArcIntern<T>
impl<T> Sync for ArcIntern<T>
impl<T> Unpin for ArcIntern<T>
impl<T> UnwindSafe for ArcIntern<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<!> for 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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
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>,