Struct imprint::Val [] [src]

pub struct Val<'x, T> { /* fields omitted */ }

A value imprinted at the type level.

A Val<'x, T> value contains an instance of T as well as a marker 'x that reflects the value of that instance at the type level. This provides a type-safe mechanism to constrain values even if their actual values are not known at compile time.

Val can be constructed using either imprint(...) or Default::default().

The underlying value can be obtained either by dererefencing or by calling .into_inner().

Properties

The notion of "value" is determined by the equivalence relation formed by Eq, or the partial equivalence relation formed by PartialEq.

We expect the value of T must be immutable through &T. Otherwise, the properties in this section would not hold. Therefore, Val is not very useful for types with interior mutability like Cell or RefCell. Moreover, keep in mind that any unsafe code can violate these properties as well.

  • If T forms an equivalence relation, then for every marker 'x, the type Val<'x, T> contains precisely one value, and each value corresponds to a unique 'x. Hence, Val<'x, T> may be considered a singleton type (unrelated to "singletons" in OOP).

  • On the other hand, if T forms a partial equivalence relation, then for every marker 'x, the type Val<'x, T> contains either a single identifiable value (for which equality is reflexive), or a single unidentifiable value (one for which equality is nonreflexive), and each identifiable value corresponds to a unique marker 'x.

Methods

impl<'x, T> Val<'x, T>
[src]

impl<'x, T: PartialEq> Val<'x, T>
[src]

Checks whether two values are equal. If they are, evidence of their equality is returned.

Trait Implementations

impl<'x, T: Clone> Clone for Val<'x, T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'x, T: Copy> Copy for Val<'x, T>
[src]

impl<'x, T: Eq> Eq for Val<'x, T>
[src]

impl<'x, T: PartialEq> PartialEq for Val<'x, T>
[src]

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

This method tests for !=.

impl<'x, T: Ord> Ord for Val<'x, T>
[src]

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

impl<'x, T: PartialOrd> PartialOrd for Val<'x, 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<'x, T: Hash> Hash for Val<'x, T>
[src]

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

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

impl<'x, T: Debug> Debug for Val<'x, T>
[src]

Formats the value using the given formatter.

impl<T: Default> Default for Val<'static, T>
[src]

The default value always has the special marker of 'static.

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

impl<'x, T> AsRef<T> for Val<'x, T>
[src]

Performs the conversion.

impl<'x, T> Borrow<T> for Val<'x, T>
[src]

Immutably borrows from an owned value. Read more

impl<'x, T> Deref for Val<'x, T>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<'x, T> IntoInner for Val<'x, T>
[src]

Extracts the inner value.