[][src]Struct abi_stable::sabi_types::ignored_wrapper::CmpIgnored

#[repr(transparent)]
pub struct CmpIgnored<T> {
    pub value: T,
}

Wrapper type used to ignore its contents in comparisons.

Use this if you want to derive trait while ignoring the contents of fields in the PartialEq/Eq/PartialOrd/Ord/Hash traits.

It also:

  • replaces the hash of T with the hash of ().

Example

This example defines a struct with a CmpIgnored field.

use abi_stable::sabi_types::CmpIgnored;

use std::collections::HashSet;

#[derive(Debug,Clone,PartialEq,Eq,PartialOrd,Ord,Hash)]
pub struct User{
    name:String,
    surname:String,
    alt_name:CmpIgnored<String>,
}


let a=User{
    name:"J__n".to_string(),
    surname:"E____t".to_string(),
    alt_name:"Z______l P______d".to_string().into(),
};

let b=User{
    name:"J__n".to_string(),
    surname:"E____t".to_string(),
    alt_name:"H___ of B_____".to_string().into(),
};

assert_eq!(a,b);

let mut map=HashSet::new();

map.replace(a.clone());
assert_eq!( map.replace(b.clone()).unwrap().alt_name.as_str(), "Z______l P______d" );

assert_eq!(map.len(),1);
assert_eq!( map.get(&a).unwrap().alt_name.as_str(), "H___ of B_____" );

Fields

value: T

Methods

impl<T> CmpIgnored<T>[src]

pub const fn new(value: T) -> Self[src]

Constructs a CmpIgnored.

Example

use abi_stable::sabi_types::CmpIgnored;

let val=CmpIgnored::new(100);

Trait Implementations

impl<T: Clone> Clone for CmpIgnored<T>[src]

impl<T: Copy> Copy for CmpIgnored<T>[src]

impl<T> Debug for CmpIgnored<T> where
    T: Debug
[src]

impl<T: Default> Default for CmpIgnored<T>[src]

impl<T> Deref for CmpIgnored<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for CmpIgnored<T>[src]

impl<T> Display for CmpIgnored<T> where
    T: Display
[src]

impl<T> Eq for CmpIgnored<T>[src]

impl<T> From<T> for CmpIgnored<T>[src]

impl<T> GetStaticEquivalent_ for CmpIgnored<T> where
    T: __StableAbi
[src]

type StaticEquivalent = _static_CmpIgnored<__GetStaticEquivalent<T>>

impl<T> Hash for CmpIgnored<T>[src]

impl<T> Ord for CmpIgnored<T>[src]

impl<T> PartialEq<CmpIgnored<T>> for CmpIgnored<T>[src]

impl<T> PartialOrd<CmpIgnored<T>> for CmpIgnored<T>[src]

impl<T> SharedStableAbi for CmpIgnored<T> where
    T: __StableAbi
[src]

type IsNonZeroType = <T as __SharedStableAbi>::IsNonZeroType

Whether this type has a single invalid bit-pattern. Read more

type Kind = __ValueKind

The kind of abi stability of this type,there are 2: Read more

Auto Trait Implementations

impl<T> RefUnwindSafe for CmpIgnored<T> where
    T: RefUnwindSafe

impl<T> Send for CmpIgnored<T> where
    T: Send

impl<T> Sync for CmpIgnored<T> where
    T: Sync

impl<T> Unpin for CmpIgnored<T> where
    T: Unpin

impl<T> UnwindSafe for CmpIgnored<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> BorrowOwned<'a> for T where
    T: 'a + Clone
[src]

type ROwned = T

type RBorrowed = &'a T

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<This> GetConstGenericVTable for This where
    This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<This> StableAbi for This where
    This: SharedStableAbi<Kind = ValueKind>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<This> TransmuteElement for This where
    This: ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The error type returned when the conversion fails.

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more