Struct internment::ArcIntern[][src]

pub struct ArcIntern<T: Eq + Hash + Send + 'static> { /* fields omitted */ }

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 internment::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

Methods

impl<T: Eq + Hash + Send + 'static> 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 HashMap protected by a Mutex.

See how many objects have been interned. This may be helpful in analyzing memory use.

Return the number of counts for this pointer.

Trait Implementations

impl<T: Eq + Hash + Send> Send for ArcIntern<T>
[src]

impl<T: Eq + Hash + Send> Sync for ArcIntern<T>
[src]

impl<T: Eq + Hash + Send + 'static> Clone for ArcIntern<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Eq + Hash + Send> Drop for ArcIntern<T>
[src]

Executes the destructor for this type. Read more

impl<T: Eq + Hash + Send> AsRef<T> for ArcIntern<T>
[src]

Important traits for &'a mut R

Performs the conversion.

impl<T: Eq + Hash + Send> Borrow<T> for ArcIntern<T>
[src]

Important traits for &'a mut R

Immutably borrows from an owned value. Read more

impl<T: Eq + Hash + Send> Deref for ArcIntern<T>
[src]

The resulting type after dereferencing.

Important traits for &'a mut R

Dereferences the value.

impl<T: Eq + Hash + Send + Display> Display for ArcIntern<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Eq + Hash + Send> Pointer for ArcIntern<T>
[src]

Formats the value using the given formatter.

impl<T: Eq + Hash + Send + 'static> From<T> for ArcIntern<T>
[src]

Performs the conversion.

impl<T: Eq + Hash + Send + Default + 'static> Default for ArcIntern<T>
[src]

Returns the "default value" for a type. Read more

impl<T: Eq + Hash + Send> 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.

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Eq + Hash + Send> PartialEq for ArcIntern<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Eq + Hash + Send> Eq for ArcIntern<T>
[src]

impl<T: Eq + Hash + Send + PartialOrd> PartialOrd for ArcIntern<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: Eq + Hash + Send + Ord> Ord for ArcIntern<T>
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<T: Eq + Hash + Send + Serialize> Serialize for ArcIntern<T>
[src]

Serialize this value into the given Serde serializer. Read more

impl<'de, T: Eq + Hash + Send + 'static + Deserialize<'de>> Deserialize<'de> for ArcIntern<T>
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<T: Eq + Hash + Send + Debug> Debug for ArcIntern<T>
[src]

Formats the value using the given formatter. Read more