Struct by_address::ByAddress

source ·
#[repr(transparent)]
pub struct ByAddress<T>(pub T) where T: ?Sized + Deref;
Expand description

Wrapper for pointer types that implements by-address comparison.

See the crate-level documentation for details.

Equality tests and hashes on fat pointers (&dyn Trait, &[T], &str, etc) include the attribute of the fat pointer.

However, note that comparing fat pointers to trait objects can be unreliable because of Rust issue #46139. In some cases, ByThinAddress may be more useful.

Tuple Fields§

§0: T

Implementations§

source§

impl<T> ByAddress<T>
where T: ?Sized + Deref,

source

pub fn from_ref(r: &T) -> &Self

Convert &T to &ByAddress<T>.

Trait Implementations§

source§

impl<T, U> AsMut<U> for ByAddress<T>
where T: ?Sized + Deref + AsMut<U>,

source§

fn as_mut(&mut self) -> &mut U

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T, U> AsRef<U> for ByAddress<T>
where T: ?Sized + Deref + AsRef<U>,

source§

fn as_ref(&self) -> &U

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Clone for ByAddress<T>
where T: ?Sized + Deref + Clone,

source§

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

Returns a copy 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> Debug for ByAddress<T>
where T: ?Sized + Deref + Debug,

source§

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

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

impl<T> Default for ByAddress<T>
where T: ?Sized + Deref + Default,

source§

fn default() -> ByAddress<T>

Returns the “default value” for a type. Read more
source§

impl<T> Deref for ByAddress<T>
where T: ?Sized + Deref,

§

type Target = T

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<T> DerefMut for ByAddress<T>
where T: ?Sized + Deref,

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

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

source§

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

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

impl<T> From<T> for ByAddress<T>
where T: Deref,

source§

fn from(t: T) -> ByAddress<T>

Converts to this type from the input type.
source§

impl<T> Hash for ByAddress<T>
where T: ?Sized + Deref,

Raw pointer hashing

source§

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

Feeds this value into the given Hasher. Read more
source§

impl<T> Ord for ByAddress<T>
where T: ?Sized + Deref,

Raw pointer ordering

source§

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

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

impl<T> PartialEq for ByAddress<T>
where T: ?Sized + Deref,

Raw pointer equality

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialOrd for ByAddress<T>
where T: ?Sized + Deref,

Raw pointer comparison

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

This method 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

This method 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

This method 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

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

impl<T> Copy for ByAddress<T>
where T: ?Sized + Deref + Copy,

source§

impl<T> Eq for ByAddress<T>
where T: ?Sized + Deref,

Auto Trait Implementations§

§

impl<T: ?Sized> Freeze for ByAddress<T>
where T: Freeze,

§

impl<T: ?Sized> RefUnwindSafe for ByAddress<T>
where T: RefUnwindSafe,

§

impl<T: ?Sized> Send for ByAddress<T>
where T: Send,

§

impl<T: ?Sized> Sync for ByAddress<T>
where T: Sync,

§

impl<T: ?Sized> Unpin for ByAddress<T>
where T: Unpin,

§

impl<T: ?Sized> UnwindSafe for ByAddress<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> 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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.