Skip to main content

Set

Struct Set 

Source
pub struct Set<T>
where T: Key,
{ /* private fields */ }
Expand description

A fixed set with storage specialized through the Key trait.

§Examples

use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum Part {
    One,
    Two,
}

#[derive(Clone, Copy, Key)]
enum MyKey {
    Simple,
    Composite(Part),
    String(&'static str),
    Number(u32),
    Singleton(()),
    Option(Option<Part>),
    Boolean(bool),
}

let mut set = Set::new();

set.insert(MyKey::Simple);
set.insert(MyKey::Composite(Part::One));
set.insert(MyKey::String("foo"));
set.insert(MyKey::Number(1));
set.insert(MyKey::Singleton(()));
set.insert(MyKey::Option(None));
set.insert(MyKey::Option(Some(Part::One)));
set.insert(MyKey::Boolean(true));

assert!(set.contains(MyKey::Simple));
assert!(set.contains(MyKey::Composite(Part::One)));
assert!(!set.contains(MyKey::Composite(Part::Two)));
assert!(set.contains(MyKey::String("foo")));
assert!(!set.contains(MyKey::String("bar")));
assert!(set.contains(MyKey::Number(1)));
assert!(!set.contains(MyKey::Number(2)));
assert!(set.contains(MyKey::Singleton(())));
assert!(set.contains(MyKey::Option(None)));
assert!(set.contains(MyKey::Option(Some(Part::One))));
assert!(!set.contains(MyKey::Option(Some(Part::Two))));
assert!(set.contains(MyKey::Boolean(true)));
assert!(!set.contains(MyKey::Boolean(false)));

Implementations§

Source§

impl<T> Set<T>
where T: Key,

A set implementation that uses fixed storage.

§Examples

use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let mut m = Set::new();
m.insert(MyKey::First);

assert_eq!(m.contains(MyKey::First), true);
assert_eq!(m.contains(MyKey::Second), false);

Using a composite key:

use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum Part {
    A,
    B,
}

#[derive(Clone, Copy, Key)]
enum MyKey {
    Simple,
    Composite(Part),
}

let mut m = Set::new();
m.insert(MyKey::Simple);
m.insert(MyKey::Composite(Part::A));

assert_eq!(m.contains(MyKey::Simple), true);
assert_eq!(m.contains(MyKey::Composite(Part::A)), true);
assert_eq!(m.contains(MyKey::Composite(Part::B)), false);
Source

pub fn new() -> Set<T>

Creates an empty Set.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    One,
    Two,
}

let set: Set<MyKey> = Set::new();
Source

pub fn iter(&self) -> Iter<'_, T>

An iterator visiting all values in arbitrary order. The iterator element type is T.

§Examples
use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, PartialEq, Eq)]
enum MyKey {
    One,
    Two,
    Three,
}

let mut set = Set::new();
set.insert(MyKey::One);
set.insert(MyKey::Two);

assert_eq!(set.iter().collect::<Vec<_>>(), vec![MyKey::One, MyKey::Two]);
Source

pub fn contains(&self, value: T) -> bool

Returns true if the set currently contains the given value.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    One,
    Two,
}

let mut set = Set::new();
set.insert(MyKey::One);
assert_eq!(set.contains(MyKey::One), true);
assert_eq!(set.contains(MyKey::Two), false);
Source

pub fn insert(&mut self, value: T) -> bool

Adds a value to the set.

If the set did not have this value present, true is returned.

If the set did have this value present, false is returned.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    One,
    Two,
}

let mut set = Set::new();
assert!(set.insert(MyKey::One));
assert!(!set.is_empty());

set.insert(MyKey::Two);
assert!(!set.insert(MyKey::Two));
assert!(set.contains(MyKey::Two));
Source

pub fn remove(&mut self, value: T) -> bool

Removes a value from the set. Returns true if the value was present in the set.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    One,
    Two,
}

let mut set = Set::new();
set.insert(MyKey::One);
assert_eq!(set.remove(MyKey::One), true);
assert_eq!(set.remove(MyKey::One), false);
Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(T) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all elements e for which f(e) returns false. The elements are visited in unsorted (and unspecified) order.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let mut set = Set::new();

set.insert(MyKey::First);
set.insert(MyKey::Second);

set.retain(|k| matches!(k, MyKey::First));

assert_eq!(set.len(), 1);
assert_eq!(set.contains(MyKey::First), true);
assert_eq!(set.contains(MyKey::Second), false);

Using a composite key:

use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    First(bool),
    Second(bool),
}

let mut set = Set::new();

set.insert(MyKey::First(true));
set.insert(MyKey::First(false));
set.insert(MyKey::Second(true));
set.insert(MyKey::Second(false));

let mut other = set.clone();
assert_eq!(set.len(), 4);

set.retain(|k| matches!(k, MyKey::First(true) | MyKey::Second(true)));

assert_eq!(set.len(), 2);
assert_eq!(set.contains(MyKey::First(true)), true);
assert_eq!(set.contains(MyKey::First(false)), false);
assert_eq!(set.contains(MyKey::Second(true)), true);
assert_eq!(set.contains(MyKey::Second(false)), false);

other.retain(|k| matches!(k, MyKey::First(_)));

assert_eq!(other.len(), 2);
assert_eq!(other.contains(MyKey::First(true)), true);
assert_eq!(other.contains(MyKey::First(false)), true);
assert_eq!(other.contains(MyKey::Second(true)), false);
assert_eq!(other.contains(MyKey::Second(false)), false);
Source

pub fn clear(&mut self)

Clears the set, removing all values.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    One,
    Two,
}

let mut set = Set::new();
set.insert(MyKey::One);
set.clear();
assert!(set.is_empty());
Source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    One,
    Two,
}

let mut set = Set::new();
assert!(set.is_empty());
set.insert(MyKey::One);
assert!(!set.is_empty());
Source

pub fn len(&self) -> usize

Returns the number of elements in the set.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let mut set = Set::new();
assert_eq!(set.len(), 0);
set.insert(MyKey::First);
assert_eq!(set.len(), 1);
Source

pub fn intersection<'a>(&'a self, other: &'a Set<T>) -> Intersection<'a, T> ⓘ

Visits the values representing the intersection, i.e., the values that are both in self and other.

When an equal element is present in self and other then the resulting Intersection may yield references to one or the other. This can be relevant if T contains fields which are not compared by its Eq implementation, and may hold different value between the two equal copies of T in the two sets.

§Examples
use fixed_map::{Key, Set};

#[derive(Clone, Copy, Key, Debug)]
enum K {
    One,
    Two,
    Three,
}

let a = Set::from([K::One]);
let b = Set::from([K::One, K::Two, K::Two]);

let intersection = a.intersection(&b).collect::<Set<_>>();
assert_eq!(intersection, Set::from([K::One]));
Source§

impl<T> Set<T>
where T: Key, T::SetStorage: RawStorage,

Source

pub fn as_raw(&self) -> <T::SetStorage as RawStorage>::Value

Get the raw value of the set.

§Examples
use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
#[key(bitset)]
enum MyKey {
    First,
    Second,
}

let mut set = Set::new();
assert!(set.as_raw() == 0);
set.insert(MyKey::First);
assert!(set.as_raw() != 0);

let set2 = Set::from_raw(set.as_raw());
assert_eq!(set, set2);
Source

pub fn from_raw(raw: <T::SetStorage as RawStorage>::Value) -> Self

Construct the set from a raw value.

§Examples
use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
#[key(bitset)]
enum MyKey {
    First,
    Second,
}

let mut set = Set::new();
assert!(set.as_raw() == 0);
set.insert(MyKey::First);
assert!(set.as_raw() != 0);

let set2 = Set::from_raw(set.as_raw());
assert_eq!(set, set2);

Trait Implementations§

Source§

impl<T> Clone for Set<T>
where T: Key, T::SetStorage: Clone,

Clone implementation for a Set.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
enum MyKey {
    First(bool),
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First(true));
let mut b = a.clone();
b.insert(MyKey::Second);

assert_ne!(a, b);

assert!(a.contains(MyKey::First(true)));
assert!(!a.contains(MyKey::Second));

assert!(b.contains(MyKey::First(true)));
assert!(b.contains(MyKey::Second));
Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for Set<T>
where T: Key, T::SetStorage: Copy,

The Copy implementation for a Set depends on its Key. If the derived key only consists of unit variants the corresponding Set will be Copy as well.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First);
let mut b = a;
b.insert(MyKey::Second);

assert_ne!(a, b);

assert!(a.contains(MyKey::First));
assert!(!a.contains(MyKey::Second));

assert!(b.contains(MyKey::First));
assert!(b.contains(MyKey::Second));
Source§

impl<T> Debug for Set<T>
where T: Key + Debug,

The Debug implementation for a Set.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First);

assert_eq!("{First}", format!("{:?}", a));
Source§

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

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

impl<'de, M, A, T> Decode<'de, M, A> for Set<T>
where A: Allocator, T: Key + Decode<'de, M, A>,

Available on crate feature musli02 only.
Source§

fn decode<D>(decoder: D) -> Result<Self, D::Error>
where D: Decoder<'de, Mode = M, Allocator = A>,

Decode the current value.
Source§

const IS_BITWISE_DECODE: bool = false

Whether the type is packed. Packed types can be bitwise copied if the representation of the serialization format is identical to the memory layout of the type. Read more
Source§

impl<T> Default for Set<T>
where T: Key,

The Default implementation for a Set produces an empty set.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let a = Set::<MyKey>::default();
let b = Set::<MyKey>::new();

assert_eq!(a, b);
Source§

fn default() -> Self

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

impl<'de, T> Deserialize<'de> for Set<T>
where T: Key + Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<M, T> Encode<M> for Set<T>
where T: Key + Encode<M>,

Available on crate feature musli02 only.
Source§

type Encode = Set<T>

The underlying type being encoded. Read more
Source§

fn encode<E>(&self, encoder: E) -> Result<(), E::Error>
where E: Encoder<Mode = M>,

Encode the given output.
Source§

fn as_encode(&self) -> &Self::Encode

Coerce into the underlying value being encoded.
Source§

const IS_BITWISE_ENCODE: bool = false

Whether the type is packed. Packed types can be bitwise copied if the representation of the serialization format is identical to the memory layout of the type. Read more
Source§

fn size_hint(&self) -> Option<usize>

The number of fields in the type.
Source§

impl<T> Eq for Set<T>
where T: Key, T::SetStorage: Eq,

Source§

impl<T, const N: usize> From<[T; N]> for Set<T>
where T: Key,

Source§

fn from(arr: [T; N]) -> Self

§Examples
use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, PartialEq, Eq)]
enum K {
    One,
    Two,
    Three,
}

let set1 = Set::from([K::One, K::Two, K::Three]);
let set2: Set<_> = [K::One, K::Two, K::Three].into();
assert_eq!(set1, set2);
Source§

impl<T> FromIterator<T> for Set<T>
where T: Key,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

impl<T> Hash for Set<T>
where T: Key, T::SetStorage: Hash,

Hash implementation for a Set.

§Examples

use std::collections::HashSet;

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, Hash)]
enum MyKey {
    First,
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First);

let mut set = HashSet::new();
set.insert(a);

Using a composite key:

use std::collections::HashSet;

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, Hash)]
enum MyKey {
    First(bool),
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First(true));

// TODO: support this
// let mut set = HashSet::new();
// set.insert(a);
Source§

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

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<'a, T> IntoIterator for &'a Set<T>
where T: Key,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = <<T as Key>::SetStorage as SetStorage<T>>::Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for Set<T>
where T: Key,

Produce an owning iterator which iterates over all elements in the set in order.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, PartialEq, Eq)]
enum MyKey {
    First,
    Second,
    Third,
}

let mut set = Set::new();
set.insert(MyKey::First);
set.insert(MyKey::Second);

assert_eq!(set.into_iter().collect::<Vec<_>>(), vec![MyKey::First, MyKey::Second]);
Source§

fn into_iter(self) -> Self::IntoIter

An iterator visiting all values in arbitrary order. The iterator element type is T.

§Examples
use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, PartialEq, Eq)]
enum MyKey {
    One,
    Two,
    Three,
}

let mut set = Set::new();
set.insert(MyKey::One);
set.insert(MyKey::Two);

assert_eq!(set.into_iter().collect::<Vec<_>>(), vec![MyKey::One, MyKey::Two]);
Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = <<T as Key>::SetStorage as SetStorage<T>>::IntoIter

Which kind of iterator are we turning this into?
Source§

impl<T> Ord for Set<T>
where T: Key, T::SetStorage: Ord,

Ord implementation for a Set.

For more details on ordering, see the Key documentation.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, Hash)]
enum MyKey {
    First,
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First);

let mut b = Set::new();
b.insert(MyKey::Second);

let mut list = vec![b, a];
list.sort();

assert_eq!(list, [a, b]);

Using a composite key:

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, Hash)]
enum MyKey {
    First(bool),
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First(true));

let mut b = Set::new();
b.insert(MyKey::Second);

// TODO: support this
// let mut list = vec![a, b];
// list.sort();
Source§

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

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

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

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

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

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

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<T> PartialEq for Set<T>
where T: Key, T::SetStorage: PartialEq,

PartialEq implementation for a Set.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
enum MyKey {
    First,
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First);
// Note: `a` is Copy since it's using a simple key.
let mut b = a;

assert_eq!(a, b);

b.insert(MyKey::Second);
assert_ne!(a, b);

Using a composite key:

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key)]
enum MyKey {
    First(bool),
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First(true));
let mut b = a.clone();

assert_eq!(a, b);

b.insert(MyKey::Second);
assert_ne!(a, b);
Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T> PartialOrd for Set<T>
where T: Key, T::SetStorage: PartialOrd,

PartialOrd implementation for a Set.

For more details on ordering, see the Key documentation.

§Examples

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, Hash)]
enum MyKey {
    First,
    Second,
    Third,
}

let mut a = Set::new();
a.insert(MyKey::First);

let mut b = Set::new();
b.insert(MyKey::Third);

assert!(a < b);

let mut empty = Set::new();
assert!(empty < a);
assert!(empty < b);

Using a composite key:

use fixed_map::{Key, Set};

#[derive(Debug, Clone, Copy, Key, Hash)]
enum MyKey {
    First(bool),
    Second,
}

let mut a = Set::new();
a.insert(MyKey::First(true));

let mut b = Set::new();
b.insert(MyKey::Second);

// TODO: support this
// assert!(a < b);
Source§

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

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

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

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

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

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

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

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

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

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

impl<T> Serialize for Set<T>
where T: Key + Serialize,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> ZeroCopy for Set<T>

Available on crate feature musli-zerocopy01 only.
Source§

const ANY_BITS: bool = <<T::SetStorage as RawStorage>::Value as musli_zerocopy01::ZeroCopy>::ANY_BITS

Indicates if the type can inhabit all possible bit patterns within its size_of::<Self>() bytes.
Source§

const PADDED: bool = <<T::SetStorage as RawStorage>::Value as musli_zerocopy01::ZeroCopy>::PADDED

Indicates if a type is padded.
Source§

const CAN_SWAP_BYTES: bool = <<T::SetStorage as RawStorage>::Value as musli_zerocopy01::ZeroCopy>::CAN_SWAP_BYTES

Indicates if the type has a valid byte-ordered transformation. Read more
Source§

fn swap_bytes<E>(self) -> Self
where E: ByteOrder,

Swap the bytes of self using the specified byte ordering to match the native byte ordering. Read more
Source§

fn initialize_padding(&mut self)

Ensure that the padding for the current value is initialized. Read more
Source§

fn to_bytes(&self) -> &[u8] ⓘ

Convert a mutable reference to a ZeroCopy type into bytes. Read more
Source§

fn to_bytes_padded(&mut self) -> &[u8] ⓘ

Convert a reference to a ZeroCopy type into bytes assuming it might be Self::PADDED. Read more
Source§

unsafe fn to_bytes_unchecked(&self) -> &[u8] ⓘ

Convert a ZeroCopy type into bytes. Read more
Source§

fn to_bytes_mut(&mut self) -> &mut [u8] ⓘ

Convert a mutable reference to a ZeroCopy type into mutable bytes requring !Self::PADDED. Read more
Source§

fn to_bytes_mut_padded(&mut self) -> &mut [u8] ⓘ

Convert a mutable reference to a ZeroCopy type into mutable bytes assuming it might be Self::PADDED. Read more
Source§

unsafe fn to_bytes_mut_unchecked(&mut self) -> &mut [u8] ⓘ

Convert a ZeroCopy type into mutable bytes. Read more
Source§

fn from_bytes(bytes: &[u8]) -> Result<&Self, Error>

Load bytes into a reference of Self. Read more
Source§

fn from_bytes_mut(bytes: &mut [u8]) -> Result<&mut Self, Error>

Load bytes into a mutable reference of Self. Read more
Source§

unsafe fn from_bytes_mut_padded(bytes: &mut [u8]) -> Result<&mut Self, Error>

Load bytes into a mutable reference of Self assuming it is Self::PADDED. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Set<T>
where <T as Key>::SetStorage: Freeze,

§

impl<T> RefUnwindSafe for Set<T>
where <T as Key>::SetStorage: RefUnwindSafe,

§

impl<T> Send for Set<T>
where <T as Key>::SetStorage: Send,

§

impl<T> Sync for Set<T>
where <T as Key>::SetStorage: Sync,

§

impl<T> Unpin for Set<T>
where <T as Key>::SetStorage: Unpin,

§

impl<T> UnsafeUnpin for Set<T>
where <T as Key>::SetStorage: UnsafeUnpin,

§

impl<T> UnwindSafe for Set<T>
where <T as Key>::SetStorage: 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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<M, D, A> DecodeOwned<M, A> for D
where D: for<'de> Decode<'de, M, A>, A: Allocator,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Pointee for T
where T: ZeroCopy,

Source§

type Metadata = ()

Source§

type Stored<O: Size> = ()

Source§

fn try_from_metadata<O>(_: ()) -> Result<<T as Pointee>::Stored<O>, CoerceError>
where O: Size,

Source§

fn to_metadata<O>(_: ()) -> <T as Pointee>::Metadata
where O: Size,

Source§

fn size(_: <T as Pointee>::Metadata) -> Option<usize>

Source§

fn align(_: <T as Pointee>::Metadata) -> usize

Source§

fn pointee_layout(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.