Struct libintern::Intern[][src]

pub struct Intern<'a, T: 'a>(_);
Expand description

A reference to an interned item.

The main advantage of this type over just an immutable reference is that its pointer is guaranteed to be unique within a single Interner. Therefore comparisons are very cheap.

Note about hashing

This wrapper implements PartialEq by comparing its inner pointer. In order to keep consistency, the Hash trait is also implemented by hashing the pointer, NOT the inner value. Therefore hashes of the Intern<T> type are different than hashes of the T.

Implementations

Create a new Intern type from a raw pointer.

Safety

The caller must guarantee that the pointed value is in fact owned by an Interner which is still in scope (i.e. not dropped) and that the pointer will not be mutated and/or moved.

Trait Implementations

Performs the conversion.

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

To keep consistency with PartialEq, we hash the pointer, not the value

Feeds this value into the given Hasher. Read more

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

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

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

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.