Interned

Struct Interned 

Source
pub struct Interned<T: Hash> { /* private fields */ }
Expand description

The main type of this crate. Represents a unique, heap-allocated, statically interned value that will exist for the life of the program.

Two instances of Interned for the same value T will always have the same heap memory address. Additionally, Interned values can be copied freely, since they are merely heap pointers.

Implementations§

Source§

impl<T: Hash> Interned<T>

Source

pub fn as_ptr(&self) -> *const ()

Provides raw access to the raw heap pointer for this Interned value. Doing something substantive with this value is unsafe. Useful for testing.

Source§

impl<T: Hash + Staticize + DataType<Type = Slice>> Interned<T>

Source

pub fn interned_slice<'a>(&self) -> &'a [T::SliceValueType]

Returns a the underlying slice interned in this Interned. Calling this method on a non-slice will panic.

Source§

impl Interned<&str>

Source

pub fn interned_str<'a>(&self) -> &'a str

Returns a reference to the underlying &str interned in this Interned. Calling this method on a non-string will panic.

Source§

impl Interned<&OsStr>

Source

pub fn interned_os_str<'a>(&self) -> &'a OsStr

Returns a reference to the underlying &OsStr interned in this Interned. Calling this method on a non-OsStr will panic.

Source§

impl Interned<&Path>

Source

pub fn interned_path<'a>(&self) -> &'a Path

Returns a reference to the underlying &Path interned in this Interned. Calling this method on a non-Path will panic.

Source§

impl<T: Hash + Staticize + DataType<Type = Value>> Interned<T>

Source

pub fn interned_value<'a>(&self) -> &'a T

Returns a reference to the underlying T interned in this Interned. Calling this method on a non-value will panic.

Trait Implementations§

Source§

impl<T: Clone + Hash> Clone for Interned<T>

Source§

fn clone(&self) -> Interned<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Hash + Staticize + DataType + Debug> Debug for Interned<T>
where <T as DataType>::SliceValueType: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Hash + Staticize + DataType> Deref for Interned<T>

Source§

type Target = <T as DataType>::DerefTargetType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: Hash + Display> Display for Interned<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Interned<&[bool]>> for &[bool]

Source§

fn from(value: Interned<&[bool]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[i128]>> for &[i128]

Source§

fn from(value: Interned<&[i128]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[i16]>> for &[i16]

Source§

fn from(value: Interned<&[i16]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[i32]>> for &[i32]

Source§

fn from(value: Interned<&[i32]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[i64]>> for &[i64]

Source§

fn from(value: Interned<&[i64]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[i8]>> for &[i8]

Source§

fn from(value: Interned<&[i8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[u128]>> for &[u128]

Source§

fn from(value: Interned<&[u128]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[u16]>> for &[u16]

Source§

fn from(value: Interned<&[u16]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[u32]>> for &[u32]

Source§

fn from(value: Interned<&[u32]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[u64]>> for &[u64]

Source§

fn from(value: Interned<&[u64]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[u8]>> for &[u8]

Source§

fn from(value: Interned<&[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&[usize]>> for &[usize]

Source§

fn from(value: Interned<&[usize]>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&OsStr>> for &OsStr

Source§

fn from(value: Interned<&OsStr>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&'static OsStr>> for InOsStr

Source§

fn from(value: Interned<&'static OsStr>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&Path>> for &Path

Source§

fn from(value: Interned<&Path>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&'static Path>> for InPath

Source§

fn from(value: Interned<&'static Path>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&str>> for &str

Source§

fn from(value: Interned<&str>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<&'static str>> for InStr

Source§

fn from(value: Interned<&'static str>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<bool>> for bool

Source§

fn from(value: Interned<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<char>> for char

Source§

fn from(value: Interned<char>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<i128>> for i128

Source§

fn from(value: Interned<i128>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<i16>> for i16

Source§

fn from(value: Interned<i16>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<i32>> for i32

Source§

fn from(value: Interned<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<i64>> for i64

Source§

fn from(value: Interned<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<i8>> for i8

Source§

fn from(value: Interned<i8>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<u128>> for u128

Source§

fn from(value: Interned<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<u16>> for u16

Source§

fn from(value: Interned<u16>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<u32>> for u32

Source§

fn from(value: Interned<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<u64>> for u64

Source§

fn from(value: Interned<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<u8>> for u8

Source§

fn from(value: Interned<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<Interned<usize>> for usize

Source§

fn from(value: Interned<usize>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash + Copy + Staticize + DataType> From<Static> for Interned<T>

Source§

fn from(value: Static) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash + Copy + Staticize + DataType + From<Interned<T>>> From<T> for Interned<T::Static>
where <T as Staticize>::Static: Hash + Sized,

Source§

fn from(value: T) -> Interned<T::Static>

Converts to this type from the input type.
Source§

impl<T: Hash + Staticize> Hash for Interned<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl<T: Hash + Staticize + Ord + DataType> Ord for Interned<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: Hash + PartialEq + Staticize + DataType> PartialEq for Interned<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Hash + Staticize + PartialOrd + DataType> PartialOrd for Interned<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Copy + Hash> Copy for Interned<T>

Source§

impl<T> Eq for Interned<T>

Auto Trait Implementations§

§

impl<T> Freeze for Interned<T>

§

impl<T> RefUnwindSafe for Interned<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Interned<T>

§

impl<T> !Sync for Interned<T>

§

impl<T> Unpin for Interned<T>
where T: Unpin,

§

impl<T> UnwindSafe for Interned<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.