Cell

Struct Cell 

Source
pub struct Cell { /* private fields */ }
Expand description

Cell represents the basic unit of Grid.

Consists of global positions global_width: u8 and global_depth: u8, alongside with methods implementing common mathematical operations for safe interactions with grids and other cells

Due to low memory size, Cell implements Copy trait, so all methods take self (copy) as first argument

§Examples

You can create Cell using new(global_width, global_depth):

use grid_math::Cell;

let cell = Cell::new(10, 15);

Or use functionality of implemented From and Into traits:

use grid_math::Cell;

let cell = Cell::from((9, 9));
let cell: Cell = (6, 7).into();

To read global_width or global_depth values, use getters:

use grid_math::Cell;

let cell = Cell::new(10, 10);
let w = cell.global_width();
let d = cell.global_depth();

Or use into() provided by Into trait:

use grid_math::Cell;

let cell = Cell::new(10, 10);
let (w, d): (u8, u8) = cell.into();

‘Cell’ implements Display and Debug trait, so you can easily print it out:

use grid_math::Cell;

let cell = Cell::new(10, 10);
println!("Cell: {cell}"); // Cell: (10, 10)
assert_eq!(format!("{cell}"), "(10, 10)");

Other methods involve interactions with Grid

Cell is designed to not mutate it’s contents. Instead, all operations return new instances of Cell

Also worth noting, that all operations on Cell are verified to be logically correct, otherwise logically incorrect operations will be met with panic!

Here is a brief overview of Cell and Grid interactions:

Check if Cell is within the Grid:

use grid_math::{Cell, Grid};

let cell = Cell::new(3, 4);
let grid = Grid::new(10, 10); // 10x10 grid starting at (0,0)
assert!(cell.within(grid));

Get relative to the Grid position of Cell: (Grid can start not only from (0,0))

use grid_math::{Cell, Grid};

let cell = Cell::new(3, 4);
let grid = Grid::indented(8, 8, (2, 1)); // 8x8 grid starting at (2,1)
let (width, depth) = (cell.width(grid), cell.depth(grid));
// cell's width on grid = cell.global_width - grid.start.global_width
// cell's depth on grid = cell.global_depth - grid.start.global_depth
assert_eq!((width, depth), (1, 3));
// get gaps between width and depth grid borders and cell:
let (width_gap, depth_gap) = (cell.width_gap(grid), cell.depth_gap(grid));
assert_eq!((width_gap, depth_gap), (6, 4));
// get member of grid by relative position:
let member = grid.member(width, depth);
assert_eq!(cell, member);

Perform some move calculations of Cell on Grid:

use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = grid.start(); // get grid's first cell
let next = cell.strict_right(grid, 3); // move to the right by 3, panics if grid bounds overflow occures
assert_eq!(next, Cell::new(3, 0));
let next = cell.saturating_down(grid, 15); // move down by 15, returns grid bound if overflow occures
assert_eq!(next, Cell::new(0, 9));
let next = cell.wrapping_right(grid, 5).strict_left(grid, 2).project_down(grid); // chain of movements
assert_eq!(next, Cell::new(3, 9));

To get more examples, look at Cell and Grid methods documentation.

Implementations§

Source§

impl Cell

Source

pub fn new(global_width: u8, global_depth: u8) -> Self

Creates new Cell with specified global_width: u8 and global_depth: u8 global position

§Examples
use grid_math::Cell;

let cell = Cell::new(10, 15);
Source

pub fn within(self, grid: Grid) -> bool

Checks if the Cell is within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(5, 5);
assert!(cell.within(grid));

let cell = Cell::new(9, 15);
assert!(!cell.within(grid));
Source

pub fn within_panic(self, grid: Grid)

Checks if the Cell is within the given Grid

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(9, 15);
cell.within_panic(grid);
Source

pub fn global_width(self) -> u8

Returns global_width field of Cell

§Examples
use grid_math::Cell;

let cell = Cell::new(8, 8);
let w = cell.global_width();
assert_eq!(w, 8);
Source

pub fn global_depth(self) -> u8

Returns global_depth field of Cell

§Examples
use grid_math::Cell;

let cell = Cell::new(8, 8);
let d = cell.global_depth();
assert_eq!(d, 8);
Source

pub fn width(self, grid: Grid) -> u8

Calculates the width of the Cell relative to the given Grid width here means position / index / x of Cell on width axis

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let cell = Cell::new(8, 8);
let grid = Grid::indented(7, 7, (4, 4)); // 7x7 grid starting at (4,4)
let width = cell.width(grid); // width = 4
assert_eq!(width, 4);
Source

pub fn width_gap(self, grid: Grid) -> u8

Calculates the gap between the width of Cell and the width of Grid

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let cell = Cell::new(8, 8);
let grid = Grid::indented(7, 7, (4, 4)); // 7x7 grid starting at (4,4)
let width_gap = cell.width_gap(grid); // width_gap = 2
assert_eq!(width_gap, 2);
Source

pub fn depth(self, grid: Grid) -> u8

Calculates the depth of Cell relative to the given Grid depth here means position / index / y of Cell on depth axis

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let cell = Cell::new(8, 8);
let grid = Grid::indented(7, 7, (4, 4)); // 7x7 grid starting at (4,4)
let depth = cell.depth(grid); // depth = 4
assert_eq!(depth, 4);
Source

pub fn depth_gap(self, grid: Grid) -> u8

Calculates the gap between the depth of Cell and the depth of Grid

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let cell = Cell::new(8, 8);
let grid = Grid::indented(7, 7, (4, 4)); // 7x7 grid starting at (4,4)
let depth_gap = cell.depth_gap(grid); // depth_gap = 2
assert_eq!(depth_gap, 2);
Source

pub fn will_underflow_depth(self, grid: Grid, step: u8) -> bool

Checks if the up operation on Cell will violate the given Grid upper border

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
assert!(cell.will_underflow_depth(grid, 3));
assert!(!cell.will_underflow_depth(grid, 2));
Source

pub fn will_overflow_depth(self, grid: Grid, step: u8) -> bool

Checks if the down operation on Cell will violate the given Grid lower border

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
assert!(cell.will_overflow_depth(grid, 3));
assert!(!cell.will_overflow_depth(grid, 2));
Source

pub fn will_underflow_width(self, grid: Grid, step: u8) -> bool

Checks if the left operation on Cell will violate the given Grid left border

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
assert!(cell.will_underflow_width(grid, 3));
assert!(!cell.will_underflow_width(grid, 2));
Source

pub fn will_overflow_width(self, grid: Grid, step: u8) -> bool

Checks if the right operation on Cell will violate the given Grid right border

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
assert!(cell.will_overflow_width(grid, 3));
assert!(!cell.will_overflow_width(grid, 2));
Source

pub fn strict_up(self, grid: Grid, step: u8) -> Cell

Moves current Cell upwards by step relative to the given Grid This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid Panics if this operation will violate the given Grid upper border

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.strict_up(grid, 2);
assert_eq!(next, Cell::new(2, 0));
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.strict_up(grid, 3); // panic!
Source

pub fn strict_down(self, grid: Grid, step: u8) -> Cell

Moves current Cell downwards by step relative to the given Grid This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid Panics if this operation will violate the given Grid lower border

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.strict_down(grid, 2);
assert_eq!(next, Cell::new(7, 9));
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.strict_down(grid, 3); // panic!
Source

pub fn strict_left(self, grid: Grid, step: u8) -> Cell

Moves current Cell to the left by step relative to the given Grid This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid Panics if this operation will violate the given Grid left border

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.strict_left(grid, 2);
assert_eq!(next, Cell::new(0, 2));
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.strict_left(grid, 3); // panic!
Source

pub fn strict_right(self, grid: Grid, step: u8) -> Cell

Moves current Cell to the right by step relative to the given Grid This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid Panics if this operation will violate the given Grid right border

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.strict_right(grid, 2);
assert_eq!(next, Cell::new(9, 7));
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.strict_right(grid, 3); // panic!
Source

pub fn saturating_up(self, grid: Grid, step: u8) -> Cell

Moves current Cell upwards by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

If this operation will cross Grid upper border, returns Cell with depth = Grid upper depth limit

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.saturating_up(grid, 2);
assert_eq!(next, Cell::new(2, 0));
let next = cell.saturating_up(grid, 5);
assert_eq!(next, Cell::new(2, 0));
Source

pub fn saturating_down(self, grid: Grid, step: u8) -> Cell

Moves current Cell downwards by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

If this operation will cross Grid lower border, returns Cell with depth = Grid lower depth limit

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.saturating_down(grid, 2);
assert_eq!(next, Cell::new(7, 9));
let next = cell.saturating_down(grid, 5);
assert_eq!(next, Cell::new(7, 9));
Source

pub fn saturating_left(self, grid: Grid, step: u8) -> Cell

Moves current Cell to the left by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

If this operation will cross Grid left border, returns Cell with width = Grid left width limit

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.saturating_left(grid, 2);
assert_eq!(next, Cell::new(0, 2));
let next = cell.saturating_left(grid, 5);
assert_eq!(next, Cell::new(0, 2));
Source

pub fn saturating_right(self, grid: Grid, step: u8) -> Cell

Moves current Cell to the right by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

If this operation will cross Grid right border, returns Cell with width = Grid right width limit

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.saturating_right(grid, 2);
assert_eq!(next, Cell::new(9, 7));
let next = cell.saturating_right(grid, 5);
assert_eq!(next, Cell::new(9, 7));
Source

pub fn overflowing_up(self, grid: Grid, step: u8) -> (Cell, bool)

Moves current Cell upwards by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell and bool

This operation is similar to the overflowing operations on integer types It returns new Cell and ‘bool’ signaling that overflow happened

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let (next, overflowed) = cell.overflowing_up(grid, 2);
assert_eq!((next, overflowed), (Cell::new(2, 0), false));
let (next, overflowed) = cell.overflowing_up(grid, 5);
assert_eq!((next, overflowed), (Cell::new(2, 7), true));
Source

pub fn overflowing_down(self, grid: Grid, step: u8) -> (Cell, bool)

Moves current Cell downwards by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell and bool

This operation is similar to the overflowing operations on integer types It returns new Cell and ‘bool’ signaling that overflow happened

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let (next, overflowed) = cell.overflowing_down(grid, 2);
assert_eq!((next, overflowed), (Cell::new(7, 9), false));
let (next, overflowed) = cell.overflowing_down(grid, 5);
assert_eq!((next, overflowed), (Cell::new(7, 2), true));
Source

pub fn overflowing_left(self, grid: Grid, step: u8) -> (Cell, bool)

Moves current Cell to the left by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell and bool

This operation is similar to the overflowing operations on integer types It returns new Cell and ‘bool’ signaling that overflow happened

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let (next, overflowed) = cell.overflowing_left(grid, 2);
assert_eq!((next, overflowed), (Cell::new(0, 2), false));
let (next, overflowed) = cell.overflowing_left(grid, 5);
assert_eq!((next, overflowed), (Cell::new(7, 2), true));
Source

pub fn overflowing_right(self, grid: Grid, step: u8) -> (Cell, bool)

Moves current Cell to the right by step relative to the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell and bool

This operation is similar to the overflowing operations on integer types It returns new Cell and ‘bool’ signaling that overflow happened

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let (next, overflowed) = cell.overflowing_right(grid, 2);
assert_eq!((next, overflowed), (Cell::new(9, 7), false));
let (next, overflowed) = cell.overflowing_right(grid, 5);
assert_eq!((next, overflowed), (Cell::new(2, 7), true));
Source

pub fn wrapping_up(self, grid: Grid, step: u8) -> Cell

Moves current Cell upwards by step relative to the given Grid

This operation is a wrapper around the overflowing_up() method, and returns only new Cell, without bool

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.wrapping_up(grid, 2);
assert_eq!(next, Cell::new(2, 0));
let next = cell.wrapping_up(grid, 5);
assert_eq!(next, Cell::new(2, 7));
Source

pub fn wrapping_down(self, grid: Grid, step: u8) -> Cell

Moves current Cell downwards by step relative to the given Grid

This operation is a wrapper around the overflowing_down() method, and returns only new Cell, without bool

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.wrapping_down(grid, 2);
assert_eq!(next, Cell::new(7, 9));
let next = cell.wrapping_down(grid, 5);
assert_eq!(next, Cell::new(7, 2));
Source

pub fn wrapping_left(self, grid: Grid, step: u8) -> Cell

Moves current Cell to the left by step relative to the given Grid

This operation is a wrapper around the overflowing_left() method, and returns only new Cell, without bool

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.wrapping_left(grid, 2);
assert_eq!(next, Cell::new(0, 2));
let next = cell.wrapping_left(grid, 5);
assert_eq!(next, Cell::new(7, 2));
Source

pub fn wrapping_right(self, grid: Grid, step: u8) -> Cell

Moves current Cell to the right by step relative to the given Grid

This operation is a wrapper around the overflowing_right() method, and returns only new Cell, without bool

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.wrapping_right(grid, 2);
assert_eq!(next, Cell::new(9, 7));
let next = cell.wrapping_right(grid, 5);
assert_eq!(next, Cell::new(2, 7));
Source

pub fn project_up(self, grid: Grid) -> Cell

Projects current Cell onto the top side of the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.project_up(grid);
assert_eq!(next, Cell::new(2, 0));
Source

pub fn project_down(self, grid: Grid) -> Cell

Projects current Cell onto the bottom side of the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.project_down(grid);
assert_eq!(next, Cell::new(7, 9));
Source

pub fn project_left(self, grid: Grid) -> Cell

Projects current Cell onto the left side of the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(2, 2);
let next = cell.project_left(grid);
assert_eq!(next, Cell::new(0, 2));
Source

pub fn project_right(self, grid: Grid) -> Cell

Projects current Cell onto the right side of the given Grid

This operation does not mutate current Cell fields, instead it calculates new position and returns new Cell

§Panics

Panics if the Cell is not within the given Grid

§Examples
use grid_math::{Cell, Grid};

let grid = Grid::new(10, 10);
let cell = Cell::new(7, 7);
let next = cell.project_right(grid);
assert_eq!(next, Cell::new(9, 7));

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

Returns a duplicate 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 Cell

Source§

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

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

impl Display for Cell

Source§

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

implements display for Cell

§Examples
use grid_math::Cell;

let cell = Cell::new(5, 6);
assert_eq!(format!("{cell}"), "(5, 6)");
Source§

impl From<(u8, u8)> for Cell

Source§

fn from(value: (u8, u8)) -> Self

implements constructor for Cell from (u8, u8)

§Examples
use grid_math::Cell;

let pos = (5, 6);
let cell = Cell::from(pos);
assert_eq!((pos.0, pos.1), (cell.global_width(), cell.global_depth()));
Source§

impl Hash for Cell

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 Into<(u8, u8)> for Cell

Source§

fn into(self) -> (u8, u8)

implements conversion from Cell into (u8, u8)

§Examples
use grid_math::Cell;

let cell = Cell::new(5, 6);
let pos: (u8, u8) = cell.into();
assert_eq!((pos.0, pos.1), (cell.global_width(), cell.global_depth()));
Source§

impl PartialEq for Cell

Source§

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

Source§

impl Eq for Cell

Source§

impl StructuralPartialEq for Cell

Auto Trait Implementations§

§

impl Freeze for Cell

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnwindSafe for Cell

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.