maze_wasm::wasm_common

Struct MazeWasm

Source
pub struct MazeWasm {
    pub maze: Maze,
}

Fields§

§maze: Maze

Implementations§

Source§

impl MazeWasm

Source

pub fn new() -> Result<MazeWasm, JsValue>

Creates a new maze instance

§Returns

A new maze instance

§Examples

Create a new maze and print its dimensions (which will be 0 rows x 0 columns)

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    import init, { MazeWasm } from 'maze_wasm.js';
        ///     try {
        let maze = new MazeWasm();
        console.log("Successfully created maze. Dimensions: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn reset(&mut self) -> MazeWasm

Resets the maze instance to empty

§Returns

The empty maze instance

§Examples

Create a new maze, resize it to 10 rows x 5 columns and print out its dimensions. Then, reset it and print out its dimensions again (which will now be 0 rows x 0 columns).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        console.log("After resize(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.reset();
        console.log("After reset(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn resize( &mut self, new_row_count: JsValue, new_col_count: JsValue, ) -> Result<(), JsValue>

Resizes the maze instance

§Arguments
  • new_row_count - New number of rows
  • new_col_count - New number of columns
§Returns

This function will return an error if the maze could not be resized

§Examples

Create a new maze, print its dimensions, resize it to 10 rows x 5 columns and then print out its dimensions again.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm ();
        console.log("After creation, dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s   )");
        maze.resize(10, 5);
        console.log("After resize(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn insert_rows( &mut self, start_row: JsValue, count: JsValue, ) -> Result<(), JsValue>

Inserts one or more empty rows into the maze instance

§Arguments
  • start_row - Start row index (zero-based)
  • count - Number of rows to insert
§Returns

This function will return an error in the following situations:

  • If the target rows are out of range
§Examples

Create a new maze, print its dimensions, insert 5 rows and then print out its dimensions again (which will now be 5 rows x 0 columns).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        console.log("After creation, dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.insert_rows(0, 5);
        console.log("After insert_rows(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn delete_rows( &mut self, start_row: JsValue, count: JsValue, ) -> Result<(), JsValue>

Deletes one or more consecutive rows from the maze instance

§Arguments
  • start_row - Start row index (zero-based)
  • count - Number of rows to delete
§Returns

This function will return an error in the following situations:

  • If the definition is empty
  • If the target rows are out of range
§Examples

Create a new maze, insert 5 rows and print out its dimensions. Then, delete rows 2 to 4 and print out the dimensions again (which will now be 2 rows x 0 columns).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        console.log("After creation, dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.insert_rows(0, 5);
        console.log("After insert_rows(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.delete_rows(1, 3);
        console.log("After delete_rows(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn insert_cols( &mut self, start_col: JsValue, count: JsValue, ) -> Result<(), JsValue>

Inserts one or more empty columns into the maze instance

§Arguments
  • start_col - Start column index (zero-based)
  • count - Number of columns to insert
§Returns

This function will return an error in the following situations:

  • If the definition is empty
  • If the target columns are out of range
§Examples

Create a new maze, insert 1 row and print out its dimensions. Then, insert 10 colums and print out the dimensions again (which will now be 1 row x 10 columns).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        console.log("After creation, dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.insert_rows(0, 1);
        console.log("After insert_rows(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.insert_cols(0, 10);
        console.log("After insert_cols(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn delete_cols( &mut self, start_col: JsValue, count: JsValue, ) -> Result<(), JsValue>

Deletes one or more consecutive columns from the maze instance

§Arguments
  • start_col - Start column index (zero-based)
  • count - Number of columns to delete
§Returns

This function will return an error in the following situations:

  • If the definition is empty
  • If the target columns are out of range
§Examples

Create a new maze, resize it to 10 rows x 5 column and print out its dimensions. Then, delete columns 2 to 4 and print out the dimensions again (which will now be 10 rows x 2 columns).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        console.log("After resize(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
        maze.delete_cols(1, 3);
        console.log("After delete_cols(), dimensions are: ", maze.get_row_count(), "row(s) x ", maze.get_col_count(), " column(s)");
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn is_empty(&self) -> bool

Checks whether the maze instance is empty

§Returns

Boolean

§Examples

Create a new maze and print out whether it is empty (true). Then, resize it to 1 row x 2 columns and again print out whether it is empty (false).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        console.log("After creation, is_empty() = ", maze.is_empty());
        maze.resize(1,2);
        console.log("After resize(), is_empty() = ", maze.is_empty());
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn get_row_count(&self) -> usize

Returns the number of rows associated with the maze instance

§Returns

Number of rows

§Examples

Create a new maze and print out the number rows (0). Then, resize it to 10 rows x 5 columns and then print out the number of rows again (10).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        console.log("After creation, get_row_count() = ", maze.get_row_count());
        maze.resize(10, 5);
        console.log("After resize(), get_row_count() = ", maze.get_row_count());
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn get_col_count(&self) -> usize

Returns the number of columns associated with the maze instance

§Returns

Number of columns

§Examples

Create a new maze and print out the number columns (0). Then, resize it to 10 rows x 5 columns and then print out the number of columns again (5).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        console.log("After creation, get_col_count() = ", maze.get_col_count());
        maze.resize(10, 5);
        console.log("After resize(), get_col_count() = ", maze.get_col_count());
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn get_cell(&self, row: JsValue, col: JsValue) -> Result<Object, JsValue>

Returns cell information for the given location within the maze instance

§Arguments
  • row - Row index (zero-based)
  • col - Column index (zero-based)
§Returns

This function will return an error in the following situations:

  • If the target location is out of range

If sucessful, a cell information object will be returned with the following properties:

§Examples

Create a new maze and resize it to 10 rows x 5 columns. Then, print out the cell information for the cell at row = 1, column = 2.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        console.log("get_cell(1, 2) = ", maze.get_cell(1, 2));
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn set_start_cell( &mut self, start_row: JsValue, start_col: JsValue, ) -> Result<(), JsValue>

Sets the start cell location within the maze instance

§Arguments
  • start_row - Start cell row index (zero-based)
  • start_col - Start cell column index (zero-based)
§Returns

This function will return an error in the following situations:

  • If the target location is out of range
§Examples

Create a new maze, resize it to 10 rows x 5 columns and print out the cell information for the cell at row = 1, column = 2 (cell_type will be MazeCellTypeWasm::Empty). Then, set the start cell to that same location and print out the cell information again (cell_type will now be MazeCellTypeWasm::Start).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        console.log("Before set_start_cell(), get_cell(1, 2) = ", maze.get_cell(1, 2));
        maze.set_start_cell(1, 2);
        console.log("After set_start_cell(), get_cell(1, 2) = ", maze.get_cell(1, 2));
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn get_start_cell(&mut self) -> Result<Object, JsValue>

Returns the start cell associated with the maze instance (if any)

§Returns

This function will return an error in the following situations:

  • If the start cell does not exist

If sucessful, an object will be returned with the following properties:

  • row - Start cell row index (zero-based)
  • col - Start cell column index (zero-based)
§Examples

Create a new maze, resize it to 10 rows x 5 columns and set the start cell to be at row = 1, column = 2. Then, retreive and print out of the details for the start cell.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        maze.set_start_cell(1, 2);
        console.log("get_start_cell() = ", maze.get_start_cell());
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn set_finish_cell( &mut self, finish_row: JsValue, finish_col: JsValue, ) -> Result<(), JsValue>

Sets the finish cell location within the maze instance

§Arguments
  • finish_row - Finish cell row index (zero-based)
  • finish_col - Finish cell column index (zero-based)
§Returns

This function will return an error in the following situations:

  • If the target location is out of range
§Examples

Create a new maze, resize it to 10 rows x 5 columns and print out the cell information for the cell at row = 3, column = 4 (cell_type will be MazeCellTypeWasm::Empty). Then, set the finish cell to that same location and print out the cell information again (cell_type will now be MazeCellTypeWasm::Finish).

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        console.log("Before set_finish_cell(), get_cell(3, 4) = ", maze.get_cell(3, 4));
        maze.set_finish_cell(3, 4);
        console.log("After set_finish_cell(), get_cell(3, 4) = ", maze.get_cell(3, 4));
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn get_finish_cell(&mut self) -> Result<Object, JsValue>

Returns the finish cell associated with the maze instance (if any)

§Returns

This function will return an error in the following situations:

  • If the finish cell does not exist

If sucessful, an object will be returned with the following properties:

  • row - Finish cell row index (zero-based)
  • col - Finish cell column index (zero-based)
§Examples

Create a new maze, resize it to 10 rows x 5 columns and set the finish cell to be at row = 9, column = 4. Then, retreive and print out of the details for the finish cell.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        maze.set_finish_cell(9, 4);
        console.log("get_finish_cell() = ", maze.get_finish_cell());
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn set_wall_cells( &mut self, start_row: JsValue, start_col: JsValue, end_row: JsValue, end_col: JsValue, ) -> Result<(), JsValue>

Sets a range of cells within the maze instance to be walls (cell_type = MazeCellTypeWasm::Wall)

§Arguments
  • start_row - Start row index (zero-based)
  • start_col - Start column index (zero-based)
  • finish_row - Finish row index (zero-based)
  • finish_col - Finish column index (zero-based)
§Returns

This function will return an error in the following situations:

  • If the target location is out of range
§Examples

Create a new maze, resize it to 10 rows x 5 columns and then set cells 2 to 4 to be walls in the first row. Then print the cell information for the top row, which will have cells (0, 0) and (0, 4) as MazeCellTypeWasm::Empty and cells (0, 1) to (0, 3) as MazeCellTypeWasm::Wall.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        maze.set_wall_cells(0, 1, 0, 3);
        for (let col  = 0; col < 5; col ++) {
            console.log(`After set_walls_cell(), cell_type at (0, ${col}) = `, maze.get_cell(0, col).cell_type);
        }
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn clear_cells( &mut self, start_row: JsValue, start_col: JsValue, end_row: JsValue, end_col: JsValue, ) -> Result<(), JsValue>

Clears a range of cells within the maze instance, setting their cell_type = MazeCellTypeWasm::Empty

§Arguments
  • start_row - Start row index (zero-based)
  • start_col - Start column index (zero-based)
  • finish_row - Finish row index (zero-based)
  • finish_col - Finish column index (zero-based)
§Returns

This function will return an error in the following situations:

  • If the target location is out of range
§Examples

Create a new maze, resize it to 10 rows x 5 columns and then set cells 2 to 4 to be walls in the first row. Then print the cell_type for the top row, which will have cells (0, 0) and (0, 4) as MazeCellTypeWasm::Empty and cells (0, 1) to (0, 3) as MazeCellTypeWasm::Wall. Finally, clear cells (0, 2) to (3, 4) and reprint the cell_type for the top row, which will now have just once cell (0, 1) as MazeCellTypeWasm::Wall.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(10, 5);
        maze.set_wall_cells(0, 1, 0, 3);
        for (let col  = 0; col < 5; col ++) {
            console.log(`After set_walls_cell(), cell_type at (0, ${col}) = `, maze.get_cell(0, col).cell_type);
        }
        maze.clear_cells(0, 2, 3, 4);
        for (let col  = 0; col < 5; col ++) {
            console.log(`After clear_walls(), cell_type at (0, ${col}) = `, maze.get_cell(0, col).cell_type);
        }
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn to_json(&self) -> Result<String, JsValue>

This function will return the JSON string representation for the maze instance

§Returns

JSON string representing the maze, or an error if the JSON could not be generated

§Examples

Create a new maze, resize it to 6 rows x 5 columns and then set cells 2 to 4 to be walls in the first 3 rows. The conver to JSON and print the result.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.resize(6, 5);
        maze.set_wall_cells(0, 1, 2, 4);
        let json = maze.to_json();
        console.log("to_json() returned: ", json);
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn from_json(&mut self, json_string: JsValue) -> Result<(), JsValue>

Initializes the maze instance by reading the JSON string content provided

§Returns

This function will return an error if the JSON could not be read

§Examples

Create a new maze and initialise it from a JSON string. Then, print the cell_type for each cell.

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.from_json(`{
            \"id\":\"maze_id\",
            \"name\":\"test\",
            \"definition\": {
                \"grid\":[
                    [\"S\", \"W\", \" \", \" \", \"W\"],
                    [\" \", \"W\", \" \", \"W\", \" \"],
                    [\" \", \" \", \" \", \"W\", \"F\"],
                    [\"W\", \" \", \"W\", \" \", \" \"],
                    [\" \", \" \", \" \", \"W\", \" \"],
                    [\"W\", \"W\", \" \", \" \", \" \"],
                    [\"W\", \"W\", \" \", \"W\", \" \"]
                ]
        }}`);
        for (let row  = 0; row < maze.get_row_count(); row ++) {
            for (let col  = 0; col < maze.get_col_count(); col ++) {
                console.log(`After from_json(), cell_type at (${row}, ${col}) = `, maze.get_cell(row, col).cell_type);
            }
        }
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();
Source

pub fn solve(&self) -> Result<MazeSolutionWasm, JsValue>

Attempts to solve the path between the start and end points defined within the maze instance

§Returns

A maze solution (MazeSolutionWasm) if successful, else an error if the maze could not be solved

§Examples

Initialize a maze from a JSON string, then attempt to solve it and, if successful, print the maze solution path’s points

// Javascript <script> content:

import init, { MazeWasm } from 'maze_wasm.js';

async function run() {
    await init();

    try {
        let maze = new MazeWasm();
        maze.from_json(`{
            \"id\":\"maze_id\",
            \"name\":\"test\",
            \"definition\": {
                \"grid\":[
                    [\"S\", \"W\", \" \", \" \", \"W\"],
                    [\" \", \"W\", \" \", \"W\", \" \"],
                    [\" \", \" \", \" \", \"W\", \"F\"],
                    [\"W\", \" \", \"W\", \" \", \" \"],
                    [\" \", \" \", \" \", \"W\", \" \"],
                    [\"W\", \"W\", \" \", \" \", \" \"],
                    [\"W\", \"W\", \" \", \"W\", \" \"]
                ]
        }}`);
        let solution = maze.solve();
        let solutionPoints = solution.get_path_points();
        console.log("Maze solve() succeeded. Solution points are: ", solutionPoints);
    } catch (e) {
        console.error("Operation failed: ", e);
    }
}
run();

Trait Implementations§

Source§

impl Clone for MazeWasm

Source§

fn clone(&self) -> Self

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 From<MazeWasm> for JsValue

Source§

fn from(value: MazeWasm) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for MazeWasm

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for MazeWasm

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for MazeWasm

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<MazeWasm>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for MazeWasm

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for MazeWasm

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for MazeWasm

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<MazeWasm>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for MazeWasm

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<MazeWasm>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for MazeWasm

Source§

type Error = JsValue

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

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl VectorFromWasmAbi for MazeWasm

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[MazeWasm]>

Source§

impl VectorIntoJsValue for MazeWasm

Source§

impl VectorIntoWasmAbi for MazeWasm

Source§

impl WasmDescribe for MazeWasm

Source§

impl WasmDescribeVector for MazeWasm

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, 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> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
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.