bit_int

Struct BitInt

Source
pub struct BitInt<T: Signed + PrimInt, const N: u32>(/* private fields */);
Expand description

BitInt is a type that represents a N-bit signed integer.

The largest size of N is equal to the size of the underlying type in bits.

§Examples

use bit_int::BitInt;

let n = BitInt::<i32, 33>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

Implementations§

Source§

impl<const N: u32> BitInt<i8, N>

Source

pub const MIN: Self = _

The smallest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i8, 7>::MIN.get(), -64);
Source

pub const MAX: Self = _

The largest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i8, 7>::MAX.get(), 63);
Source

pub const BITS: u32 = N

The size of this BitInt in bits.

§Examples
assert_eq!(BitInt::<i8, 7>::BITS, 7);
Source§

impl<const N: u32> BitInt<i16, N>

Source

pub const MIN: Self = _

The smallest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i16, 7>::MIN.get(), -64);
Source

pub const MAX: Self = _

The largest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i16, 7>::MAX.get(), 63);
Source

pub const BITS: u32 = N

The size of this BitInt in bits.

§Examples
assert_eq!(BitInt::<i16, 7>::BITS, 7);
Source§

impl<const N: u32> BitInt<i32, N>

Source

pub const MIN: Self = _

The smallest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i32, 7>::MIN.get(), -64);
Source

pub const MAX: Self = _

The largest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i32, 7>::MAX.get(), 63);
Source

pub const BITS: u32 = N

The size of this BitInt in bits.

§Examples
assert_eq!(BitInt::<i32, 7>::BITS, 7);
Source§

impl<const N: u32> BitInt<i64, N>

Source

pub const MIN: Self = _

The smallest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i64, 7>::MIN.get(), -64);
Source

pub const MAX: Self = _

The largest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i64, 7>::MAX.get(), 63);
Source

pub const BITS: u32 = N

The size of this BitInt in bits.

§Examples
assert_eq!(BitInt::<i64, 7>::BITS, 7);
Source§

impl<const N: u32> BitInt<i128, N>

Source

pub const MIN: Self = _

The smallest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i128, 7>::MIN.get(), -64);
Source

pub const MAX: Self = _

The largest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<i128, 7>::MAX.get(), 63);
Source

pub const BITS: u32 = N

The size of this BitInt in bits.

§Examples
assert_eq!(BitInt::<i128, 7>::BITS, 7);
Source§

impl<const N: u32> BitInt<isize, N>

Source

pub const MIN: Self = _

The smallest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<isize, 7>::MIN.get(), -64);
Source

pub const MAX: Self = _

The largest value that can be represented by this BitInt.

§Examples
assert_eq!(BitInt::<isize, 7>::MAX.get(), 63);
Source

pub const BITS: u32 = N

The size of this BitInt in bits.

§Examples
assert_eq!(BitInt::<isize, 7>::BITS, 7);
Source§

impl<const N: u32> BitInt<i8, N>

Source

pub const fn checked_add(self, rhs: i8) -> Option<Self>

Computes self + rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i8, 7>::new(42).unwrap();

assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
assert!(n.checked_add(22).is_none());
Source

pub const fn checked_sub(self, rhs: i8) -> Option<Self>

Computes self - rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i8, 7>::new(-42).unwrap();

assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
assert!(n.checked_sub(23).is_none());
Source

pub const fn checked_mul(self, rhs: i8) -> Option<Self>

Computes self * rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i8, 7>::new(21).unwrap();

assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
assert!(n.checked_mul(4).is_none());
Source

pub const fn checked_div(self, rhs: i8) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

§Examples
let n = BitInt::<i8, 7>::new(42).unwrap();

assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
assert!(n.checked_div(0).is_none());

assert!(BitInt::<i8, 7>::MIN.checked_div(-1).is_none());
Source§

impl<const N: u32> BitInt<i16, N>

Source

pub const fn checked_add(self, rhs: i16) -> Option<Self>

Computes self + rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i16, 7>::new(42).unwrap();

assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
assert!(n.checked_add(22).is_none());
Source

pub const fn checked_sub(self, rhs: i16) -> Option<Self>

Computes self - rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i16, 7>::new(-42).unwrap();

assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
assert!(n.checked_sub(23).is_none());
Source

pub const fn checked_mul(self, rhs: i16) -> Option<Self>

Computes self * rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i16, 7>::new(21).unwrap();

assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
assert!(n.checked_mul(4).is_none());
Source

pub const fn checked_div(self, rhs: i16) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

§Examples
let n = BitInt::<i16, 7>::new(42).unwrap();

assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
assert!(n.checked_div(0).is_none());

assert!(BitInt::<i16, 7>::MIN.checked_div(-1).is_none());
Source§

impl<const N: u32> BitInt<i32, N>

Source

pub const fn checked_add(self, rhs: i32) -> Option<Self>

Computes self + rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i32, 7>::new(42).unwrap();

assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
assert!(n.checked_add(22).is_none());
Source

pub const fn checked_sub(self, rhs: i32) -> Option<Self>

Computes self - rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i32, 7>::new(-42).unwrap();

assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
assert!(n.checked_sub(23).is_none());
Source

pub const fn checked_mul(self, rhs: i32) -> Option<Self>

Computes self * rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i32, 7>::new(21).unwrap();

assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
assert!(n.checked_mul(4).is_none());
Source

pub const fn checked_div(self, rhs: i32) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

§Examples
let n = BitInt::<i32, 7>::new(42).unwrap();

assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
assert!(n.checked_div(0).is_none());

assert!(BitInt::<i32, 7>::MIN.checked_div(-1).is_none());
Source§

impl<const N: u32> BitInt<i64, N>

Source

pub const fn checked_add(self, rhs: i64) -> Option<Self>

Computes self + rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i64, 7>::new(42).unwrap();

assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
assert!(n.checked_add(22).is_none());
Source

pub const fn checked_sub(self, rhs: i64) -> Option<Self>

Computes self - rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i64, 7>::new(-42).unwrap();

assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
assert!(n.checked_sub(23).is_none());
Source

pub const fn checked_mul(self, rhs: i64) -> Option<Self>

Computes self * rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i64, 7>::new(21).unwrap();

assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
assert!(n.checked_mul(4).is_none());
Source

pub const fn checked_div(self, rhs: i64) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

§Examples
let n = BitInt::<i64, 7>::new(42).unwrap();

assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
assert!(n.checked_div(0).is_none());

assert!(BitInt::<i64, 7>::MIN.checked_div(-1).is_none());
Source§

impl<const N: u32> BitInt<i128, N>

Source

pub const fn checked_add(self, rhs: i128) -> Option<Self>

Computes self + rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i128, 7>::new(42).unwrap();

assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
assert!(n.checked_add(22).is_none());
Source

pub const fn checked_sub(self, rhs: i128) -> Option<Self>

Computes self - rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i128, 7>::new(-42).unwrap();

assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
assert!(n.checked_sub(23).is_none());
Source

pub const fn checked_mul(self, rhs: i128) -> Option<Self>

Computes self * rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<i128, 7>::new(21).unwrap();

assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
assert!(n.checked_mul(4).is_none());
Source

pub const fn checked_div(self, rhs: i128) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

§Examples
let n = BitInt::<i128, 7>::new(42).unwrap();

assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
assert!(n.checked_div(0).is_none());

assert!(BitInt::<i128, 7>::MIN.checked_div(-1).is_none());
Source§

impl<const N: u32> BitInt<isize, N>

Source

pub const fn checked_add(self, rhs: isize) -> Option<Self>

Computes self + rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<isize, 7>::new(42).unwrap();

assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
assert!(n.checked_add(22).is_none());
Source

pub const fn checked_sub(self, rhs: isize) -> Option<Self>

Computes self - rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<isize, 7>::new(-42).unwrap();

assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
assert!(n.checked_sub(23).is_none());
Source

pub const fn checked_mul(self, rhs: isize) -> Option<Self>

Computes self * rhs, returning None if overflow occurred.

§Examples
let n = BitInt::<isize, 7>::new(21).unwrap();

assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
assert!(n.checked_mul(4).is_none());
Source

pub const fn checked_div(self, rhs: isize) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

§Examples
let n = BitInt::<isize, 7>::new(42).unwrap();

assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
assert!(n.checked_div(0).is_none());

assert!(BitInt::<isize, 7>::MIN.checked_div(-1).is_none());
Source§

impl<const N: u32> BitInt<i8, N>

Source

pub const fn new(n: i8) -> Option<Self>

Creates a new BitInt with the given signed integer value.

Returns None if the value is not a valid N-bit signed integer.

§Examples
let n = BitInt::<i8, 7>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

let m = BitInt::<i8, 6>::new(42);
assert!(m.is_none());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
assert!(!BitInt::<i8, 7>::MIN.is_positive());
assert!(BitInt::<i8, 7>::MAX.is_positive());
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
assert!(BitInt::<i8, 7>::MIN.is_negative());
assert!(!BitInt::<i8, 7>::MAX.is_negative());
Source§

impl<const N: u32> BitInt<i16, N>

Source

pub const fn new(n: i16) -> Option<Self>

Creates a new BitInt with the given signed integer value.

Returns None if the value is not a valid N-bit signed integer.

§Examples
let n = BitInt::<i16, 7>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

let m = BitInt::<i16, 6>::new(42);
assert!(m.is_none());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
assert!(!BitInt::<i16, 7>::MIN.is_positive());
assert!(BitInt::<i16, 7>::MAX.is_positive());
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
assert!(BitInt::<i16, 7>::MIN.is_negative());
assert!(!BitInt::<i16, 7>::MAX.is_negative());
Source§

impl<const N: u32> BitInt<i32, N>

Source

pub const fn new(n: i32) -> Option<Self>

Creates a new BitInt with the given signed integer value.

Returns None if the value is not a valid N-bit signed integer.

§Examples
let n = BitInt::<i32, 7>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

let m = BitInt::<i32, 6>::new(42);
assert!(m.is_none());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
assert!(!BitInt::<i32, 7>::MIN.is_positive());
assert!(BitInt::<i32, 7>::MAX.is_positive());
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
assert!(BitInt::<i32, 7>::MIN.is_negative());
assert!(!BitInt::<i32, 7>::MAX.is_negative());
Source§

impl<const N: u32> BitInt<i64, N>

Source

pub const fn new(n: i64) -> Option<Self>

Creates a new BitInt with the given signed integer value.

Returns None if the value is not a valid N-bit signed integer.

§Examples
let n = BitInt::<i64, 7>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

let m = BitInt::<i64, 6>::new(42);
assert!(m.is_none());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
assert!(!BitInt::<i64, 7>::MIN.is_positive());
assert!(BitInt::<i64, 7>::MAX.is_positive());
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
assert!(BitInt::<i64, 7>::MIN.is_negative());
assert!(!BitInt::<i64, 7>::MAX.is_negative());
Source§

impl<const N: u32> BitInt<i128, N>

Source

pub const fn new(n: i128) -> Option<Self>

Creates a new BitInt with the given signed integer value.

Returns None if the value is not a valid N-bit signed integer.

§Examples
let n = BitInt::<i128, 7>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

let m = BitInt::<i128, 6>::new(42);
assert!(m.is_none());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
assert!(!BitInt::<i128, 7>::MIN.is_positive());
assert!(BitInt::<i128, 7>::MAX.is_positive());
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
assert!(BitInt::<i128, 7>::MIN.is_negative());
assert!(!BitInt::<i128, 7>::MAX.is_negative());
Source§

impl<const N: u32> BitInt<isize, N>

Source

pub const fn new(n: isize) -> Option<Self>

Creates a new BitInt with the given signed integer value.

Returns None if the value is not a valid N-bit signed integer.

§Examples
let n = BitInt::<isize, 7>::new(42);
assert_eq!(n.map(BitInt::get), Some(42));

let m = BitInt::<isize, 6>::new(42);
assert!(m.is_none());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
assert!(!BitInt::<isize, 7>::MIN.is_positive());
assert!(BitInt::<isize, 7>::MAX.is_positive());
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
assert!(BitInt::<isize, 7>::MIN.is_negative());
assert!(!BitInt::<isize, 7>::MAX.is_negative());
Source§

impl<T: Signed + PrimInt, const N: u32> BitInt<T, N>

Source

pub const unsafe fn new_unchecked(n: T) -> Self

Creates a new BitInt with the given signed integer value.

This method does not check whether the value is a valid N-bit signed integer. This results in undefined behaviour if the value is not a valid N-bit signed integer.

§Safety

The value must be a valid N-bit signed integer.

Source

pub const fn get(self) -> T

Returns the contained value as the underlying type.

Trait Implementations§

Source§

impl<T: Signed + PrimInt + Binary, const N: u32> Binary for BitInt<T, N>

Source§

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

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

impl<T: Clone + Signed + PrimInt, const N: u32> Clone for BitInt<T, N>

Source§

fn clone(&self) -> BitInt<T, N>

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 + Signed + PrimInt, const N: u32> Debug for BitInt<T, N>

Source§

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

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

impl<T: Default + Signed + PrimInt, const N: u32> Default for BitInt<T, N>

Source§

fn default() -> BitInt<T, N>

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

impl<T: Signed + PrimInt + Display, const N: u32> Display for BitInt<T, N>

Source§

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

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

impl<T: Hash + Signed + PrimInt, const N: u32> Hash for BitInt<T, N>

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<T: Signed + PrimInt + LowerExp, const N: u32> LowerExp for BitInt<T, N>

Source§

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

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

impl<T: Signed + PrimInt + LowerHex, const N: u32> LowerHex for BitInt<T, N>

Source§

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

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

impl<T: Signed + PrimInt + Octal, const N: u32> Octal for BitInt<T, N>

Source§

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

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

impl<T: Ord + Signed + PrimInt, const N: u32> Ord for BitInt<T, N>

Source§

fn cmp(&self, other: &BitInt<T, N>) -> 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<T: PartialEq + Signed + PrimInt, const N: u32> PartialEq for BitInt<T, N>

Source§

fn eq(&self, other: &BitInt<T, 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<T: PartialOrd + Signed + PrimInt, const N: u32> PartialOrd for BitInt<T, N>

Source§

fn partial_cmp(&self, other: &BitInt<T, N>) -> 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<T: Signed + PrimInt + UpperExp, const N: u32> UpperExp for BitInt<T, N>

Source§

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

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

impl<T: Signed + PrimInt + UpperHex, const N: u32> UpperHex for BitInt<T, N>

Source§

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

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

impl<T: Copy + Signed + PrimInt, const N: u32> Copy for BitInt<T, N>

Source§

impl<T: Eq + Signed + PrimInt, const N: u32> Eq for BitInt<T, N>

Source§

impl<T: Signed + PrimInt, const N: u32> StructuralPartialEq for BitInt<T, N>

Auto Trait Implementations§

§

impl<T, const N: u32> Freeze for BitInt<T, N>
where T: Freeze,

§

impl<T, const N: u32> RefUnwindSafe for BitInt<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: u32> Send for BitInt<T, N>
where T: Send,

§

impl<T, const N: u32> Sync for BitInt<T, N>
where T: Sync,

§

impl<T, const N: u32> Unpin for BitInt<T, N>
where T: Unpin,

§

impl<T, const N: u32> UnwindSafe for BitInt<T, N>
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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>,

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.