Struct BitArray

Source
pub struct BitArray<B: BitsIn, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,
{ /* private fields */ }
Expand description

The bitarray type.

§Examples

extern crate typenum;
use bit_array::BitArray;
use typenum::U10;

let mut bv = BitArray::<u32, U10>::from_elem(false);

// insert all primes less than 10
bv.set(2, true);
bv.set(3, true);
bv.set(5, true);
bv.set(7, true);
println!("{:?}", bv);
println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());

// flip all values in bitarray, producing non-primes less than 10
bv.negate();
println!("{:?}", bv);
println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());

// reset bitarray to empty
bv.clear();
println!("{:?}", bv);
println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());

Implementations§

Source§

impl<B: BitsIn + BitBlock + Default, NBits> BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source

pub fn new() -> Self

Creates an empty BitArray.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let mut bv = BitArray::<u32, U8>::new();
Source

pub fn from_elem(bit: bool) -> Self

Creates a BitArray, setting each element to bit.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U10;

let mut bv = BitArray::<u32, U10>::from_elem(false);
assert_eq!(bv.len(), 10);
for x in bv.iter() {
    assert_eq!(x, false);
}
Source

pub fn from_bytes(bytes: &[u8]) -> Self

Transforms a byte-array into a BitArray. Each byte becomes eight bits, with the most significant bits of each byte coming first. Each bit becomes true if equal to 1 or false if equal to 0.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let bv = BitArray::<u32, U8>::from_bytes(&[0b10100000, 0b00010010]);
assert!(bv.eq_vec(&[true, false, true, false,
                    false, false, false, false,
                    false, false, false, true,
                    false, false, true, false]));
Source

pub fn from_fn<F>(f: F) -> Self
where F: FnMut(usize) -> bool,

Creates a BitArray of the specified length where the value at each index is f(index).

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U5;

let bv = BitArray::<u32, U5>::from_fn(|i| { i % 2 == 0 });
assert!(bv.eq_vec(&[true, false, true, false, true]));
Source

pub fn blocks(&self) -> Blocks<'_, B>

Iterator over the underlying blocks of data

Source

pub fn storage(&self) -> &[B]

Exposes the raw block storage of this BitArray

Only really intended for BitSet.

Source

pub unsafe fn storage_mut(&mut self) -> &mut [B]

Exposes the raw block storage of this BitArray

Can probably cause unsafety. Only really intended for BitSet.

Source

pub fn get(&self, i: usize) -> Option<bool>

Retrieves the value at index i, or None if the index is out of bounds.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let bv = BitArray::<u32, U8>::from_bytes(&[0b01100000]);
assert_eq!(bv.get(0), Some(false));
assert_eq!(bv.get(1), Some(true));
assert_eq!(bv.get(100), None);

// Can also use array indexing
assert_eq!(bv[1], true);
Source

pub fn set(&mut self, i: usize, x: bool)

Sets the value of a bit at an index i.

§Panics

Panics if i is out of bounds.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let mut bv = BitArray::<u32, U8>::from_elem(false);
bv.set(3, true);
assert_eq!(bv[3], true);
Source

pub fn set_all(&mut self)

Sets all bits to 1.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let before = 0b01100000;
let after  = 0b11111111;

let mut bv = BitArray::<u32, U8>::from_bytes(&[before]);
bv.set_all();
assert_eq!(bv, BitArray::<u32, U8>::from_bytes(&[after]));
Source

pub fn negate(&mut self)

Flips all bits.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let before = 0b01100000;
let after  = 0b10011111;

let mut bv = BitArray::<u32, U8>::from_bytes(&[before]);
bv.negate();
assert_eq!(bv, BitArray::<u32, U8>::from_bytes(&[after]));
Source

pub fn union(&mut self, other: &Self) -> bool

Calculates the union of two bitarrays. This acts like the bitwise or function.

Sets self to the union of self and other. Both bitarrays must be the same length. Returns true if self changed.

§Panics

Panics if the bitarrays are of different lengths.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let a   = 0b01100100;
let b   = 0b01011010;
let res = 0b01111110;

let mut a = BitArray::<u32, U8>::from_bytes(&[a]);
let b = BitArray::<u32, U8>::from_bytes(&[b]);

assert!(a.union(&b));
assert_eq!(a, BitArray::<u32, U8>::from_bytes(&[res]));
Source

pub fn intersect(&mut self, other: &Self) -> bool

Calculates the intersection of two bitarrays. This acts like the bitwise and function.

Sets self to the intersection of self and other. Both bitarrays must be the same length. Returns true if self changed.

§Panics

Panics if the bitarrays are of different lengths.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let a   = 0b01100100;
let b   = 0b01011010;
let res = 0b01000000;

let mut a = BitArray::<u32, U8>::from_bytes(&[a]);
let b = BitArray::<u32, U8>::from_bytes(&[b]);

assert!(a.intersect(&b));
assert_eq!(a, BitArray::<u32, U8>::from_bytes(&[res]));
Source

pub fn difference(&mut self, other: &Self) -> bool

Calculates the difference between two bitarrays.

Sets each element of self to the value of that element minus the element of other at the same index. Both bitarrays must be the same length. Returns true if self changed.

§Panics

Panics if the bitarrays are of different length.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let a   = 0b01100100;
let b   = 0b01011010;
let a_b = 0b00100100; // a - b
let b_a = 0b00011010; // b - a

let mut bva = BitArray::<u32, U8>::from_bytes(&[a]);
let bvb = BitArray::<u32, U8>::from_bytes(&[b]);

assert!(bva.difference(&bvb));
assert_eq!(bva, BitArray::<u32, U8>::from_bytes(&[a_b]));

let bva = BitArray::<u32, U8>::from_bytes(&[a]);
let mut bvb = BitArray::<u32, U8>::from_bytes(&[b]);

assert!(bvb.difference(&bva));
assert_eq!(bvb, BitArray::<u32, U8>::from_bytes(&[b_a]));
Source

pub fn all(&self) -> bool

Returns true if all bits are 1.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let mut bv = BitArray::<u32, U8>::from_elem(true);
assert_eq!(bv.all(), true);

bv.set(1, false);
assert_eq!(bv.all(), false);
Source

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

Returns an iterator over the elements of the array in order.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U16;

let bv = BitArray::<u32, U16>::from_bytes(&[0b01110100, 0b10010010]);
assert_eq!(bv.iter().filter(|x| *x).count(), 7);
Source

pub fn none(&self) -> bool

Returns true if all bits are 0.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let mut bv = BitArray::<u32, U8>::from_elem(false);
assert_eq!(bv.none(), true);

bv.set(3, true);
assert_eq!(bv.none(), false);
Source

pub fn any(&self) -> bool

Returns true if any bit is 1.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let mut bv = BitArray::<u32, U8>::from_elem(false);
assert_eq!(bv.any(), false);

bv.set(3, true);
assert_eq!(bv.any(), true);
Source

pub fn to_bytes(&self) -> Vec<u8>

Organises the bits into bytes, such that the first bit in the BitArray becomes the high-order bit of the first byte. If the size of the BitArray is not a multiple of eight then trailing bits will be filled-in with false.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::{U3, U9};

let mut bv = BitArray::<u32, U3>::from_elem(true);
bv.set(1, false);

assert_eq!(bv.to_bytes(), [0b10100000]);

let mut bv = BitArray::<u32, U9>::from_elem(false);
bv.set(2, true);
bv.set(8, true);

assert_eq!(bv.to_bytes(), [0b00100000, 0b10000000]);
Source

pub fn eq_vec(&self, v: &[bool]) -> bool

Compares a BitArray to a slice of bools. Both the BitArray and slice must have the same length.

§Panics

Panics if the BitArray and slice are of different length.

§Examples
extern crate typenum;
use bit_array::BitArray;
use typenum::U8;

let bv = BitArray::<u32, U8>::from_bytes(&[0b10100000]);

assert!(bv.eq_vec(&[true, false, true, false,
                    false, false, false, false]));
Source

pub fn len(&self) -> usize

Returns the total number of bits in this array

Source

pub fn clear(&mut self)

Clears all bits in this array.

Trait Implementations§

Source§

impl<B: BitsIn + BitBlock + Default, NBits> Clone for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
Source§

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

Performs copy-assignment from source. Read more
Source§

impl<B: BitsIn + BitBlock + Default, NBits> Debug for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

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

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

impl<B: BitsIn + BitBlock + Default, NBits> Default for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

fn default() -> Self

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

impl<B: BitsIn + BitBlock + Default, NBits> FromIterator<bool> for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

fn from_iter<I: IntoIterator<Item = bool>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<B: BitsIn + BitBlock + Default, NBits> Hash for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

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<B: BitsIn + BitBlock + Default, NBits> Index<usize> for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &bool

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, B: BitsIn + BitBlock + Default, NBits> IntoIterator for &'a BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

type Item = bool

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, B, NBits>

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

fn into_iter(self) -> Iter<'a, B, NBits>

Creates an iterator from a value. Read more
Source§

impl<B: BitsIn + BitBlock + Default, NBits> IntoIterator for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

type Item = bool

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<B, NBits>

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

fn into_iter(self) -> IntoIter<B, NBits>

Creates an iterator from a value. Read more
Source§

impl<B: BitsIn + BitBlock + Default, NBits> Ord for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

fn cmp(&self, other: &Self) -> 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<B: BitsIn + BitBlock + Default, NBits> PartialEq for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Source§

fn eq(&self, other: &Self) -> 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<B: BitsIn + BitBlock + Default, NBits> PartialOrd for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<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
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<B: BitsIn + BitBlock + Default, NBits> Eq for BitArray<B, NBits>
where NBits: Add<<B as BitsIn>::Output> + Unsigned + NonZero, <NBits as Add<<B as BitsIn>::Output>>::Output: Sub<B1>, <<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output: Div<<B as BitsIn>::Output>, <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: ArrayLength<B>,

Auto Trait Implementations§

§

impl<B, NBits> Freeze for BitArray<B, NBits>
where <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: Sized, <<<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output as ArrayLength<B>>::ArrayType: Freeze,

§

impl<B, NBits> RefUnwindSafe for BitArray<B, NBits>
where <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: Sized, <<<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output as ArrayLength<B>>::ArrayType: RefUnwindSafe,

§

impl<B, NBits> Send for BitArray<B, NBits>
where <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: Sized, <<<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output as ArrayLength<B>>::ArrayType: Send,

§

impl<B, NBits> Sync for BitArray<B, NBits>
where <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: Sized, <<<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output as ArrayLength<B>>::ArrayType: Sync,

§

impl<B, NBits> Unpin for BitArray<B, NBits>
where <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: Sized, <<<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output as ArrayLength<B>>::ArrayType: Unpin,

§

impl<B, NBits> UnwindSafe for BitArray<B, NBits>
where <<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output: Sized, <<<<NBits as Add<<B as BitsIn>::Output>>::Output as Sub<B1>>::Output as Div<<B as BitsIn>::Output>>::Output as ArrayLength<B>>::ArrayType: 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<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> Same for T

Source§

type Output = T

Should always be Self
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 = 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.