Struct DigitSequence

Source
pub struct DigitSequence(/* private fields */);
Expand description

Immutable sequence of u8 digits.

§Creation

A digit sequence is usually created via conversions - both fallible and infallible - although a constructor is provided to instantiate an empty sequence that is also its Default value.

use digit_sequence::*;

assert_eq!(DigitSequence::new(), []);
assert_eq!(DigitSequence::default(), []);

let sequence: DigitSequence = [3, 8, 7].try_into()?;
assert_eq!(sequence, [3, 8, 7]);

assert_eq!(format!("{:?}", sequence), "DigitSequence([3, 8, 7])");
assert_eq!(sequence.to_string(), "387");

For details and more code samples, please refer to the implementations of the From and TryFrom interfaces.

§Equality

Equality is firstly supported with another DigitSequence:

use digit_sequence::*;


let source = [1, 3, 5, 7, 9];

let left: DigitSequence = (&source).try_into()?;
let right: DigitSequence = (&source).try_into()?;
assert_eq!(left, right);

let other: DigitSequence = [9u8, 4u8].try_into()?;
assert_ne!(left, other);

Equality is also supported for operands of other iterable types - such as [u8], &[u8] or Vec: please, refer to the documentation for the implementations of this PartialEq.

§Order

PartialOrd is supported for DigitSequence - just as expected:

use digit_sequence::*;

let short_bigger: DigitSequence = [9].try_into()?;
let short_smaller: DigitSequence = [4].try_into()?;

let longest: DigitSequence = [9, 7].try_into()?;

assert!(short_bigger > short_smaller);
assert!(short_bigger < longest);

§Serialization

REQUIRES FEATURE: serde.

When the serde feature is enabled for this crate, DigitSequence implements the serde::Serialize and serde::Deserialize traits.

#[cfg(feature = "my_feature")]
{
    use digit_sequence::*;
    use serde_json::{to_string, from_str};

    let original: DigitSequence = 9786u16.into();
    let expected_json = "[9,7,8,6]";

    let json = to_string(&original)?;
    assert_eq!(json, expected_json);

    let deserialized: DigitSequence = from_str(expected_json)?;
    assert_eq!(deserialized, original);

}

Implementations§

Source§

impl DigitSequence

Source

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

Repeatable iteration over references to the digits.

use digit_sequence::*;

let source = [9, 5, 0, 2];
let sequence: DigitSequence = (&source).try_into()?;
let mut target: Vec<u8> = vec![];

for &digit in sequence.iter() {
    target.push(digit)
}

for &digit in sequence.iter() {
    target.push(digit)
}

let expected_vec: Vec<u8> = [&source[..], &source[..]].concat();

assert_eq!(target, expected_vec);
Source§

impl DigitSequence

Source

pub fn new() -> DigitSequence

Creates an empty sequence.

use digit_sequence::DigitSequence;

let sequence = DigitSequence::new();

assert_eq!(sequence.iter().len(), 0);
Source

pub fn is_empty(&self) -> bool

Tells whether the sequence is empty.

use digit_sequence::*;

let empty = DigitSequence::new();
assert!(empty.is_empty());

let non_empty: DigitSequence = 84u8.into();
assert!(!non_empty.is_empty());

Trait Implementations§

Source§

impl Clone for DigitSequence

Source§

fn clone(&self) -> DigitSequence

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 Debug for DigitSequence

Source§

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

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

impl Default for DigitSequence

Source§

fn default() -> DigitSequence

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

impl<'de> Deserialize<'de> for DigitSequence

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 Display for DigitSequence

The string representation of a DigitSequence is just the concatenation of its digits.

use digit_sequence::*;

let digit_sequence: DigitSequence = DigitSequence::new();
assert_eq!(digit_sequence.to_string(), "");

let digit_sequence: DigitSequence = 9u8.into();
assert_eq!(digit_sequence.to_string(), "9");

let digit_sequence: DigitSequence = 175438u32.into();
assert_eq!(digit_sequence.to_string(), "175438");
Source§

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

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

impl From<u128> for DigitSequence

Conversion from an unsigned integer to a DigitSequence is always infallible.

Source§

fn from(value: u128) -> DigitSequence

Converts to this type from the input type.
Source§

impl From<u16> for DigitSequence

Conversion from an unsigned integer to a DigitSequence is always infallible.

Source§

fn from(value: u16) -> DigitSequence

Converts to this type from the input type.
Source§

impl From<u32> for DigitSequence

Conversion from an unsigned integer to a DigitSequence is always infallible.

Source§

fn from(value: u32) -> DigitSequence

Converts to this type from the input type.
Source§

impl From<u64> for DigitSequence

Conversion from an unsigned integer to a DigitSequence is always infallible.

Source§

fn from(value: u64) -> DigitSequence

Converts to this type from the input type.
Source§

impl From<u8> for DigitSequence

Conversion from an unsigned integer to a DigitSequence is always infallible.

Source§

fn from(value: u8) -> DigitSequence

Converts to this type from the input type.
Source§

impl From<usize> for DigitSequence

Conversion from an unsigned integer to a DigitSequence is always infallible.

Source§

fn from(value: usize) -> DigitSequence

Converts to this type from the input type.
Source§

impl FromStr for DigitSequence

Parsing a &str or String works if it only consists of base-10 digits, with the exception of the empty string:

use digit_sequence::*;


let sequence: DigitSequence = "".parse()?;
assert_eq!(sequence, []);

let sequence: DigitSequence = "2".parse()?;
assert_eq!(sequence, [2]);

let sequence: DigitSequence = "0302".parse()?;
assert_eq!(sequence, [0, 3, 0, 2]);

let sequence: DigitSequence = String::from("0302").parse()?;
assert_eq!(sequence, [0, 3, 0, 2]);

Any other string pattern results in a CrateError::NonDigitChar:

use digit_sequence::*;


let result: CrateResult<DigitSequence> = "<NOT A NUMBER>".parse();
assert!(result == Err(CrateError::NonDigitChar('<')));

let result: CrateResult<DigitSequence> = "90xy".parse();
assert!(result == Err(CrateError::NonDigitChar('x')));

let result: CrateResult<DigitSequence> = "-90".parse();
assert!(result == Err(CrateError::NonDigitChar('-')));

let result: CrateResult<DigitSequence> = " 90".parse();
assert!(result == Err(CrateError::NonDigitChar(' ')));
  
Source§

type Err = CrateError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> CrateResult<Self>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for DigitSequence

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<'a> IntoIterator for &'a DigitSequence

Repeatable, reference-based iteration on &DigitSequence is supported.

use digit_sequence::*;

let source = [9, 5, 0, 2];
let sequence: DigitSequence = (&source).try_into()?;
let mut target: Vec<u8> = vec![];

for digit in &sequence {
    target.push(*digit)
}

for digit in &sequence {
    target.push(*digit)
}

let expected_vec: Vec<u8> = [&source[..], &source[..]].concat();

assert_eq!(target, expected_vec);
Source§

type Item = &'a u8

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, u8>

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 IntoIterator for DigitSequence

Consuming iteration on DigitSequence is supported:

use digit_sequence::*;

let source = [9, 5, 0, 2];
let sequence: DigitSequence = (&source).try_into()?;
let mut target: Vec<u8> = vec![];

for digit in sequence {
    target.push(digit)
}

assert_eq!(target, source);

In this case, the sequence cannot be reused once consumed:

use digit_sequence::*;

let source = [9, 5, 0, 2];
let sequence: DigitSequence = (&source).try_into()?;

for digit in sequence {
    //Just do something
}

for digit in sequence {
    //Could never arrive here
}
Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<DigitSequence as IntoIterator>::Item>

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 Ord for DigitSequence

Source§

fn cmp(&self, other: &DigitSequence) -> 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 PartialEq<&[u8]> for DigitSequence

DigitSequence can be compared with a slice of u8:

use digit_sequence::*;

let source: [u8; 4] = [8, 2, 5, 7];
let slice: &[u8] = &source;

let sequence: DigitSequence = slice.try_into()?;
assert_eq!(sequence, slice);

let other: [u8; 4] = [8, 9, 0, 0];
let other_slice: &[u8] = &other;

assert_ne!(sequence, other_slice);
Source§

fn eq(&self, other: &&[u8]) -> 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<const N: usize> PartialEq<&[u8; N]> for DigitSequence

DigitSequence supports equality with a reference to a fixed-size array.

use digit_sequence::*;

let source = [1, 3, 5, 7, 9];
let sequence: DigitSequence = (&source).try_into()?;

assert_eq!(sequence, &source);

let other = [9, 4];
assert_ne!(sequence, &other);
Source§

fn eq(&self, other: &&[u8; N]) -> 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 PartialEq<&Vec<u8>> for DigitSequence

DigitSequence supports equality with a reference to a Vec of u8.

use digit_sequence::*;


let vector = vec![1, 3, 5, 7, 9];
let sequence: DigitSequence = (&vector).try_into()?;

assert_eq!(sequence, &vector);

let other = vec![90, 92];
assert_ne!(sequence, &other);
  
Source§

fn eq(&self, other: &&Vec<u8>) -> 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<const N: usize> PartialEq<[u8; N]> for DigitSequence

DigitSequence supports equality with a fixed-size array.

use digit_sequence::*;

let source = [1, 3, 5, 7, 9];
let sequence: DigitSequence = (&source).try_into()?;

assert_eq!(sequence, source);

let other = [9, 4];
assert_ne!(sequence, other);
Source§

fn eq(&self, other: &[u8; N]) -> 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 PartialEq<Vec<u8>> for DigitSequence

DigitSequence supports equality with a Vec of u8.

use digit_sequence::*;

let vector = vec![1, 3, 5, 7, 9];
let sequence: DigitSequence = (&vector).try_into()?;

assert_eq!(sequence, vector);

let other = vec![90, 92];
assert_ne!(sequence, other);
  
Source§

fn eq(&self, other: &Vec<u8>) -> 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 PartialEq for DigitSequence

Source§

fn eq(&self, other: &DigitSequence) -> 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 PartialOrd for DigitSequence

Source§

fn partial_cmp(&self, other: &DigitSequence) -> 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 Serialize for DigitSequence

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 TryFrom<&[u8]> for DigitSequence

A slice of u8 numbers can be converted to DigitSequence as long as its values are 0-9 digits; the empty slice is also acceptable.

use digit_sequence::*;


let slice: &[u8] = &[];
let sequence: DigitSequence = slice.try_into()?;
assert_eq!(sequence, []);

let slice: &[u8] = &[9];
let sequence: DigitSequence = slice.try_into()?;
assert_eq!(sequence, [9]);

let slice: &[u8] = &[0, 5, 6, 9, 0];
let sequence: DigitSequence = slice.try_into()?;
assert_eq!(sequence, [0, 5, 6, 9, 0]);

Out-of-range numbers result in a CrateError::NonDigitNumber:

use digit_sequence::*;

let slice: &[u8] = &[10];
let sequence_result: CrateResult<DigitSequence> = slice.try_into();

assert_eq!(sequence_result, Err(CrateError::NonDigitNumber(10)));
Source§

type Error = CrateError

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

fn try_from(digits: &[u8]) -> CrateResult<Self>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<&[u8; N]> for DigitSequence

DigitSequence can be created from a reference to a u8 array, as long as the array only contains 0-9 digits or is empty; otherwise, the conversion results in a CrateError::NonDigitNumber:

use digit_sequence::*;


let sequence: DigitSequence = (&[]).try_into()?;
assert_eq!(sequence, []);

let sequence: DigitSequence = (&[9, 2]).try_into()?;
assert_eq!(sequence, [9, 2]);

let result: CrateResult<DigitSequence> = [10].try_into();
assert_eq!(result, Err(CrateError::NonDigitNumber(10)));
Source§

type Error = CrateError

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

fn try_from(digits: &[u8; N]) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&DigitSequence> for u128

Conversion from a &DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: &DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&DigitSequence> for u16

Conversion from a &DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: &DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&DigitSequence> for u32

Conversion from a &DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: &DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&DigitSequence> for u64

Conversion from a &DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: &DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&DigitSequence> for u8

Conversion from a &DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: &DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&DigitSequence> for usize

Conversion from a &DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: &DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<&Vec<u8>> for DigitSequence

DigitSequence can be created from a reference to a Vec of u8, as long as the vector only contains 0-9 digits or is empty; otherwise, the conversion results in a CrateError::NonDigitNumber:

use digit_sequence::*;


let sequence: DigitSequence = (&vec![]).try_into()?;
assert_eq!(sequence, []);

let sequence: DigitSequence = (&vec![9, 2]).try_into()?;
assert_eq!(sequence, [9, 2]);

let result: CrateResult<DigitSequence> = (&vec![10]).try_into();
assert_eq!(result, Err(CrateError::NonDigitNumber(10)));
Source§

type Error = CrateError

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

fn try_from(value: &Vec<u8>) -> CrateResult<Self>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<[u8; N]> for DigitSequence

DigitSequence can be created from an array of u8, as long as the array contains only 0-9 digits or is empty; otherwise, the conversion results in a CrateError::NonDigitNumber:

use digit_sequence::*;


let sequence: DigitSequence = [].try_into()?;
assert_eq!(sequence, []);

let sequence: DigitSequence = [9, 2].try_into()?;
assert_eq!(sequence, [9, 2]);

let result: CrateResult<DigitSequence> = [10].try_into();
assert_eq!(result, Err(CrateError::NonDigitNumber(10)));
Source§

type Error = CrateError

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

fn try_from(digits: [u8; N]) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<DigitSequence> for u128

Conversion from a DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<DigitSequence> for u16

Conversion from a DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<DigitSequence> for u32

Conversion from a DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<DigitSequence> for u64

Conversion from a DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<DigitSequence> for u8

Conversion from a DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<DigitSequence> for usize

Conversion from a DigitSequence is only available to unsigned integers.

It is always fallible - because it might result in a CrateError::Overflow.

Source§

type Error = CrateError

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

fn try_from(sequence: DigitSequence) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for DigitSequence

DigitSequence can be created from a Vec of u8, as long as the vector contains only 0-9 digits or is empty; otherwise, the conversion results in a CrateError::NonDigitNumber:

use digit_sequence::*;


let sequence: DigitSequence = vec![].try_into()?;
assert_eq!(sequence, []);

let sequence: DigitSequence = vec![9, 2].try_into()?;
assert_eq!(sequence, [9, 2]);

let result: CrateResult<DigitSequence> = vec![10].try_into();
assert_eq!(result, Err(CrateError::NonDigitNumber(10)));
Source§

type Error = CrateError

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

fn try_from(value: Vec<u8>) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<i128> for DigitSequence

Conversion from a signed integer to a DigitSequence is fallible - in particular, negative values result in CrateError::NegativeNumber.

Source§

type Error = CrateError

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

fn try_from(value: i128) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<i16> for DigitSequence

Conversion from a signed integer to a DigitSequence is fallible - in particular, negative values result in CrateError::NegativeNumber.

Source§

type Error = CrateError

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

fn try_from(value: i16) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<i32> for DigitSequence

Conversion from a signed integer to a DigitSequence is fallible - in particular, negative values result in CrateError::NegativeNumber.

Source§

type Error = CrateError

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

fn try_from(value: i32) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<i64> for DigitSequence

Conversion from a signed integer to a DigitSequence is fallible - in particular, negative values result in CrateError::NegativeNumber.

Source§

type Error = CrateError

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

fn try_from(value: i64) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<i8> for DigitSequence

Conversion from a signed integer to a DigitSequence is fallible - in particular, negative values result in CrateError::NegativeNumber.

Source§

type Error = CrateError

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

fn try_from(value: i8) -> CrateResult<Self>

Performs the conversion.
Source§

impl TryFrom<isize> for DigitSequence

Conversion from a signed integer to a DigitSequence is fallible - in particular, negative values result in CrateError::NegativeNumber.

Source§

type Error = CrateError

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

fn try_from(value: isize) -> CrateResult<Self>

Performs the conversion.
Source§

impl Eq for DigitSequence

Source§

impl StructuralPartialEq for DigitSequence

Auto Trait Implementations§

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<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.
Source§

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