merkle_log

Struct TreeID

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

Unique identifiers for binary tree nodes. Reproduced from flat-tree.

Implementations§

Source§

impl TreeID

Source

pub const ROOT: Self

The highest root TreeID of a full [MerkleLog].

Source

pub const MIN_LEAF: Self

The TreeID of the very first leaf.

Source

pub const MAX_LEAF: Self

The TreeID of the very last leaf.

Source

pub const fn new(height: u8, index: u64) -> Self

Returns a node’s unique id within the tree, given its height and index.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::new(0, 0), TreeID::from(0));
assert_eq!(TreeID::new(0, 1), TreeID::from(2));
assert_eq!(TreeID::new(0, 2), TreeID::from(4));
assert_eq!(TreeID::new(1, 0), TreeID::from(1));
assert_eq!(TreeID::new(1, 1), TreeID::from(5));
assert_eq!(TreeID::new(1, 2), TreeID::from(9));
assert_eq!(TreeID::new(1, 3), TreeID::from(13));
assert_eq!(TreeID::new(2, 0), TreeID::from(3));
assert_eq!(TreeID::new(2, 1), TreeID::from(11));
assert_eq!(TreeID::new(2, 2), TreeID::from(19));
assert_eq!(TreeID::new(3, 0), TreeID::from(7));
assert_eq!(TreeID::new(3, 1), TreeID::from(23));
Source

pub const fn first(height: u8) -> Self

Returns the first node’s unique id at a given height.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::first(0), TreeID::from(0));
assert_eq!(TreeID::first(1), TreeID::from(1));
assert_eq!(TreeID::first(2), TreeID::from(3));
// test roots
assert_eq!(TreeID::first(62), TreeID::ROOT.left().unwrap());
assert_eq!(TreeID::first(TreeID::MAX_HEIGHT), TreeID::ROOT);
Source

pub const fn last(height: u8) -> Self

Returns the last node’s unique id at a given height.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::last(0), TreeID::MAX_LEAF);
assert_eq!(TreeID::last(1), TreeID::MAX_LEAF.parent());
assert_eq!(TreeID::last(2), TreeID::MAX_LEAF.parent().parent());
// test roots
assert_eq!(TreeID::last(62), TreeID::ROOT.right().unwrap());
assert_eq!(TreeID::last(TreeID::MAX_HEIGHT), TreeID::ROOT);
Source

pub const fn leaf(index: u64) -> Self

Returns a leaf node’s unique id at a given index.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::leaf(0), TreeID::from(0));
assert_eq!(TreeID::leaf(1), TreeID::from(2));
assert_eq!(TreeID::leaf(2), TreeID::from(4));
assert_eq!(TreeID::leaf(3), TreeID::from(6));
Source

pub const fn is_leaf(&self) -> bool

Determines if the id represents a leaf node.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).is_leaf(), true);
assert_eq!(TreeID::from(1).is_leaf(), false);
assert_eq!(TreeID::from(2).is_leaf(), true);
assert_eq!(TreeID::from(3).is_leaf(), false);
Source

pub const fn is_left(&self) -> bool

Determines if the id represents a left node of its parent.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).is_left(), true);
assert_eq!(TreeID::from(1).is_left(), true);
assert_eq!(TreeID::from(2).is_left(), false);
assert_eq!(TreeID::from(3).is_left(), true);
assert_eq!(TreeID::from(4).is_left(), true);
assert_eq!(TreeID::from(5).is_left(), false);
assert_eq!(TreeID::from(6).is_left(), false);
// test root
assert_eq!(TreeID::ROOT.is_left(), true);
Source

pub const fn is_right(&self) -> bool

Determines if the id represents a right node of its parent.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).is_right(), false);
assert_eq!(TreeID::from(1).is_right(), false);
assert_eq!(TreeID::from(2).is_right(), true);
assert_eq!(TreeID::from(3).is_right(), false);
assert_eq!(TreeID::from(4).is_right(), false);
assert_eq!(TreeID::from(5).is_right(), true);
assert_eq!(TreeID::from(6).is_right(), true);
// test root
assert_eq!(TreeID::ROOT.is_right(), false);
Source

pub const fn is_left_of(&self, other: &Self) -> bool

Determines if the id represents a left node of its parent.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).is_left_of(&TreeID::from(0)), false);
assert_eq!(TreeID::from(0).is_left_of(&TreeID::from(1)), true);
assert_eq!(TreeID::from(2).is_left_of(&TreeID::from(1)), false);
assert_eq!(TreeID::from(1).is_left_of(&TreeID::from(2)), true);
Source

pub const fn is_right_of(&self, other: &Self) -> bool

Determines if the id represents a right node of its parent.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).is_right_of(&TreeID::from(0)), false);
assert_eq!(TreeID::from(0).is_right_of(&TreeID::from(1)), false);
assert_eq!(TreeID::from(2).is_right_of(&TreeID::from(1)), true);
assert_eq!(TreeID::from(1).is_right_of(&TreeID::from(2)), false);
Source

pub const fn is_first(self) -> bool

Determines if the id is the first among nodes of the same height.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).is_first(), true);
assert_eq!(TreeID::from(1).is_first(), true);
assert_eq!(TreeID::from(2).is_first(), false);
assert_eq!(TreeID::from(3).is_first(), true);
assert_eq!(TreeID::from(4).is_first(), false);
assert_eq!(TreeID::from(5).is_first(), false);
assert_eq!(TreeID::from(6).is_first(), false);
assert_eq!(TreeID::from(7).is_first(), true);
// test root
assert_eq!(TreeID::ROOT.is_first(), true);
Source

pub const fn is_last(self) -> bool

Determines if the id is the last among nodes of the same height.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::MAX_LEAF.is_last(), true);
assert_eq!(TreeID::MAX_LEAF.parent().is_last(), true);
assert_eq!(TreeID::MAX_LEAF.sibling().is_last(), false);
assert_eq!(TreeID::MAX_LEAF.parent().sibling().is_last(), false);
// test root
assert_eq!(TreeID::ROOT.is_last(), true);
Source

pub const fn index(&self) -> u64

Returns a node’s index among nodes of the same height.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).index(), 0);
assert_eq!(TreeID::from(1).index(), 0);
assert_eq!(TreeID::from(2).index(), 1);
assert_eq!(TreeID::from(3).index(), 0);
assert_eq!(TreeID::from(4).index(), 2);
assert_eq!(TreeID::from(5).index(), 1);
assert_eq!(TreeID::from(6).index(), 3);
assert_eq!(TreeID::from(7).index(), 0);
assert_eq!(TreeID::from(8).index(), 4);
assert_eq!(TreeID::from(9).index(), 2);
assert_eq!(TreeID::from(10).index(), 5);
// test root
assert_eq!(TreeID::ROOT.index(), 0);
Source

pub const fn height(&self) -> u8

Returns a node’s height in the tree.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).height(), 0);
assert_eq!(TreeID::from(1).height(), 1);
assert_eq!(TreeID::from(2).height(), 0);
assert_eq!(TreeID::from(3).height(), 2);
assert_eq!(TreeID::from(4).height(), 0);
// test root
assert_eq!(TreeID::ROOT.height(), TreeID::MAX_HEIGHT);
Source

pub const fn size(&self) -> u64

Returns the total number of nodes the node spans.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).size(), 1);
assert_eq!(TreeID::from(2).size(), 1);
assert_eq!(TreeID::from(1).size(), 3);
assert_eq!(TreeID::from(3).size(), 7);
assert_eq!(TreeID::from(7).size(), 15);
// test root
assert_eq!(TreeID::ROOT.size(), u64::MAX);
Source

pub const fn num_leaves(&self) -> u64

Returns the number of leaf nodes the node spans.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).num_leaves(), 0);
assert_eq!(TreeID::from(2).num_leaves(), 0);
assert_eq!(TreeID::from(1).num_leaves(), 2);
assert_eq!(TreeID::from(5).num_leaves(), 2);
assert_eq!(TreeID::from(3).num_leaves(), 4);
assert_eq!(TreeID::from(7).num_leaves(), 8);
// test root
assert_eq!(TreeID::ROOT.num_leaves(), TreeID::MAX_LEAF.index() + 1);
Source

pub const fn span(&self) -> (Self, Self)

Returns the left- and right-most node ids in the tree the node spans.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).span(), (TreeID::from(0), TreeID::from(0)));
assert_eq!(TreeID::from(2).span(), (TreeID::from(2), TreeID::from(2)));
assert_eq!(TreeID::from(1).span(), (TreeID::from(0), TreeID::from(2)));
assert_eq!(TreeID::from(3).span(), (TreeID::from(0), TreeID::from(6)));
assert_eq!(TreeID::from(23).span(), (TreeID::from(16), TreeID::from(30)));
assert_eq!(TreeID::from(27).span(), (TreeID::from(24), TreeID::from(30)));
// test root
assert_eq!(TreeID::ROOT.span(), (TreeID::MIN_LEAF, TreeID::MAX_LEAF));
Source

pub const fn spans(&self, other: &Self) -> bool

Determines if the id’s tree spans (i.e. contains) another id.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).spans(&TreeID::from(0)), true);
assert_eq!(TreeID::from(0).spans(&TreeID::from(1)), false);
assert_eq!(TreeID::from(0).spans(&TreeID::from(2)), false);
assert_eq!(TreeID::from(1).spans(&TreeID::from(0)), true);
assert_eq!(TreeID::from(1).spans(&TreeID::from(1)), true);
assert_eq!(TreeID::from(1).spans(&TreeID::from(2)), true);
assert_eq!(TreeID::from(3).spans(&TreeID::from(1)), true);
assert_eq!(TreeID::from(3).spans(&TreeID::from(5)), true);
assert_eq!(TreeID::from(3).spans(&TreeID::from(7)), false);
// test root
assert_eq!(TreeID::ROOT.spans(&TreeID::MIN_LEAF), true);
assert_eq!(TreeID::ROOT.spans(&TreeID::MAX_LEAF), true);
Source

pub const fn root_id(&self) -> Self

Returns the lowest root id of a [MerkleLog] that contains this node.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).root_id(), TreeID::from(0));
assert_eq!(TreeID::from(1).root_id(), TreeID::from(1));
assert_eq!(TreeID::from(2).root_id(), TreeID::from(1));
assert_eq!(TreeID::from(3).root_id(), TreeID::from(3));
assert_eq!(TreeID::from(4).root_id(), TreeID::from(3));
assert_eq!(TreeID::from(5).root_id(), TreeID::from(3));
assert_eq!(TreeID::from(6).root_id(), TreeID::from(3));
assert_eq!(TreeID::from(7).root_id(), TreeID::from(7));
assert_eq!(TreeID::from(8).root_id(), TreeID::from(7));
assert_eq!(TreeID::from(9).root_id(), TreeID::from(7));
// test root
assert_eq!(TreeID::ROOT.root_id(), TreeID::ROOT);
Source

pub const fn sort_index(&self) -> u64

Returns a node’s sort index, i.e. the index in a list sorted by when the node completes a subtree and becomes immutable.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).sort_index(), 0);
assert_eq!(TreeID::from(2).sort_index(), 1);
assert_eq!(TreeID::from(1).sort_index(), 2);
assert_eq!(TreeID::from(4).sort_index(), 3);
assert_eq!(TreeID::from(6).sort_index(), 4);
assert_eq!(TreeID::from(5).sort_index(), 5);
assert_eq!(TreeID::from(3).sort_index(), 6);
assert_eq!(TreeID::from(8).sort_index(), 7);
assert_eq!(TreeID::from(10).sort_index(), 8);
assert_eq!(TreeID::from(9).sort_index(), 9);
assert_eq!(TreeID::from(12).sort_index(), 10);
assert_eq!(TreeID::from(14).sort_index(), 11);
assert_eq!(TreeID::from(13).sort_index(), 12);
assert_eq!(TreeID::from(11).sort_index(), 13);
assert_eq!(TreeID::from(7).sort_index(), 14);
// check final nodes
assert_eq!(TreeID::MAX_LEAF.sort_index(), TreeID::MAX_SORT_INDEX - TreeID::MAX_HEIGHT as u64);
assert_eq!(TreeID::ROOT.sort_index(), TreeID::MAX_SORT_INDEX);
Source

pub const fn sibling(&self) -> Self

Returns the sibling id of a node.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).sibling(), TreeID::from(2));
assert_eq!(TreeID::from(2).sibling(), TreeID::from(0));
assert_eq!(TreeID::from(1).sibling(), TreeID::from(5));
assert_eq!(TreeID::from(5).sibling(), TreeID::from(1));
// test root
// assert_eq!(TreeID::ROOT.sibling(), TreeID::ROOT);
Source

pub const fn parent(&self) -> Self

Returns the parent id of a node.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).parent(), TreeID::from(1));
assert_eq!(TreeID::from(1).parent(), TreeID::from(3));
assert_eq!(TreeID::from(2).parent(), TreeID::from(1));
assert_eq!(TreeID::from(3).parent(), TreeID::from(7));
assert_eq!(TreeID::from(4).parent(), TreeID::from(5));
assert_eq!(TreeID::from(5).parent(), TreeID::from(3));
assert_eq!(TreeID::from(6).parent(), TreeID::from(5));
assert_eq!(TreeID::from(7).parent(), TreeID::from(15));
assert_eq!(TreeID::from(8).parent(), TreeID::from(9));
// test root
// assert_eq!(TreeID::ROOT.sibling(), TreeID::ROOT);
Source

pub const fn uncle(&self) -> Self

Given a node, returns its parent’s sibling’s id.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).uncle(), TreeID::from(5));
assert_eq!(TreeID::from(2).uncle(), TreeID::from(5));
assert_eq!(TreeID::from(1).uncle(), TreeID::from(11));
assert_eq!(TreeID::from(5).uncle(), TreeID::from(11));
assert_eq!(TreeID::from(9).uncle(), TreeID::from(3));
// test root
// assert_eq!(TreeID::ROOT.sibling(), TreeID::ROOT);
Source

pub const fn left(&self) -> Option<Self>

Returns the id of the node’s left child.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).left(), None);
assert_eq!(TreeID::from(1).left(), Some(TreeID::from(0)));
assert_eq!(TreeID::from(3).left(), Some(TreeID::from(1)));
Source

pub const fn right(&self) -> Option<Self>

Returns the id of the node’s right child.

§Examples
use merkle_log::TreeID;

assert_eq!(TreeID::from(0).right(), None);
assert_eq!(TreeID::from(1).right(), Some(TreeID::from(2)));
assert_eq!(TreeID::from(3).right(), Some(TreeID::from(5)));
Source

pub fn proving_ids(&self, to_height: u8) -> impl Iterator<Item = Self>

Given the id of a node in a balanced tree, produce the ids of nodes required for a traditional merkle tree proof, excluding the (sub)root.

§Examples
use std::collections::BTreeSet;
use merkle_log::*;

assert_eq!(TreeID::from(0).proving_ids(0).collect::<Vec<_>>(), &[]);
assert_eq!(TreeID::from(0).proving_ids(1).collect::<Vec<_>>(), &[TreeID::from(2)]);
assert_eq!(TreeID::from(0).proving_ids(2).collect::<Vec<_>>(), &[TreeID::from(2), TreeID::from(5)]);
Source

pub fn appending_ids(new_len: u64) -> impl Iterator<Item = Self>

The ids whose values are required to append the next entry to the log, sorted left to right.

§Examples
use merkle_log::*;

assert_eq!(TreeID::appending_ids(1).collect::<Vec<_>>(), &[]);
assert_eq!(TreeID::appending_ids(2).collect::<Vec<_>>(), &[TreeID::from(0)]);
assert_eq!(TreeID::appending_ids(3).collect::<Vec<_>>(), &[TreeID::from(1)]);
assert_eq!(TreeID::appending_ids(4).collect::<Vec<_>>(), &[TreeID::from(1), TreeID::from(4)]);
assert_eq!(TreeID::appending_ids(5).collect::<Vec<_>>(), &[TreeID::from(3)]);
assert_eq!(TreeID::appending_ids(6).collect::<Vec<_>>(), &[TreeID::from(3), TreeID::from(8)]);
assert_eq!(TreeID::appending_ids(7).collect::<Vec<_>>(), &[TreeID::from(3), TreeID::from(9)]);
assert_eq!(TreeID::appending_ids(8).collect::<Vec<_>>(), &[TreeID::from(3), TreeID::from(9), TreeID::from(12)]);
assert_eq!(TreeID::appending_ids(9).collect::<Vec<_>>(), &[TreeID::from(7)]);
assert_eq!(TreeID::appending_ids(10).collect::<Vec<_>>(), &[TreeID::from(7), TreeID::from(16)]);
Source

pub fn subroot_ids(len: u64) -> impl Iterator<Item = Self>

The root ids of the highest complete subtrees within a log whose length is len, sorted left to right.

§Examples
use merkle_log::*;

assert_eq!(TreeID::subroot_ids(0).collect::<Vec<_>>(), &[]);
assert_eq!(TreeID::subroot_ids(1).collect::<Vec<_>>(), &[TreeID::from(0)]);
assert_eq!(TreeID::subroot_ids(2).collect::<Vec<_>>(), &[TreeID::from(1)]);
assert_eq!(TreeID::subroot_ids(3).collect::<Vec<_>>(), &[TreeID::from(1), TreeID::from(4)]);
assert_eq!(TreeID::subroot_ids(4).collect::<Vec<_>>(), &[TreeID::from(3)]);
assert_eq!(TreeID::subroot_ids(5).collect::<Vec<_>>(), &[TreeID::from(3), TreeID::from(8)]);
assert_eq!(TreeID::subroot_ids(6).collect::<Vec<_>>(), &[TreeID::from(3), TreeID::from(9)]);
assert_eq!(TreeID::subroot_ids(7).collect::<Vec<_>>(), &[TreeID::from(3), TreeID::from(9), TreeID::from(12)]);
assert_eq!(TreeID::subroot_ids(8).collect::<Vec<_>>(), &[TreeID::from(7)]);
assert_eq!(TreeID::subroot_ids(9).collect::<Vec<_>>(), &[TreeID::from(7), TreeID::from(16)]);
assert_eq!(TreeID::subroot_ids(10).collect::<Vec<_>>(), &[TreeID::from(7), TreeID::from(17)]);
// test root
// assert_eq!(TreeID::subroot_ids(TreeID::MAX_LEN).count() as u64, 0u64);

Trait Implementations§

Source§

impl Clone for TreeID

Source§

fn clone(&self) -> TreeID

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 TreeID

Source§

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

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

impl From<u64> for TreeID

Source§

fn from(id: u64) -> Self

Converts to this type from the input type.
Source§

impl Hash for TreeID

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

Source§

fn cmp(&self, other: &TreeID) -> 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 for TreeID

Source§

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

Source§

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

Source§

impl Eq for TreeID

Source§

impl StructuralPartialEq for TreeID

Auto Trait Implementations§

§

impl Freeze for TreeID

§

impl RefUnwindSafe for TreeID

§

impl Send for TreeID

§

impl Sync for TreeID

§

impl Unpin for TreeID

§

impl UnwindSafe for TreeID

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 u8)

🔬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> 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.