Struct walrus::InstrSeqBuilder

source ·
pub struct InstrSeqBuilder<'a> { /* private fields */ }
Expand description

A builder returned by instruction sequence-construction methods to build up instructions within a block/loop/if-else over time.

Implementations§

source§

impl InstrSeqBuilder<'_>

source

pub fn id(&self) -> InstrSeqId

Returns the id of the instruction sequence that we’re building.

source

pub fn instrs(&self) -> &[(Instr, InstrLocId)]

Get this instruction sequence’s instructions.

source

pub fn instrs_mut(&mut self) -> &mut Vec<(Instr, InstrLocId)>

Get this instruction sequence’s instructions mutably.

source

pub fn instr(&mut self, instr: impl Into<Instr>) -> &mut Self

Pushes a new instruction onto this builder’s sequence.

source

pub fn instr_at( &mut self, position: usize, instr: impl Into<Instr> ) -> &mut Self

Splice a new instruction into this builder’s sequence at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn i32_const(&mut self, val: i32) -> &mut Self

Creates an i32.const instruction for the specified value.

source

pub fn i64_const(&mut self, val: i64) -> &mut Self

Creates an i64.const instruction for the specified value.

source

pub fn f32_const(&mut self, val: f32) -> &mut Self

Creates an f32.const instruction for the specified value

source

pub fn f64_const(&mut self, val: f64) -> &mut Self

Creates an f64.const instruction for the specified value

source

pub fn block( &mut self, ty: impl Into<InstrSeqType>, make_block: impl FnOnce(&mut InstrSeqBuilder<'_>) ) -> &mut Self

Append a new, nested block ... end to this builder’s sequence.

Example:
let mut module = walrus::Module::default();
let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

// Append the following WAT to the function:
//
//     block
//       i32.const 1337
//       drop
//     end
builder
    .func_body()
    .block(None, |block| {
        block
            .i32_const(1337)
            .drop();
    });
source

pub fn block_at( &mut self, position: usize, ty: impl Into<InstrSeqType>, make_block: impl FnOnce(&mut InstrSeqBuilder<'_>) ) -> &mut Self

Append a new, nested block ... end to this builder’s sequence.

Example:
let mut module = walrus::Module::default();
let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

// Make the function's body be a single `unreachable` instruction.
builder
    .func_body()
    .unreachable();

// Splice the following WAT into the function, before the `unreachable`:
//
//     block
//       i32.const 1337
//       drop
//     end
builder
    .func_body()
    .block_at(0, None, |block| {
        block
            .i32_const(1337)
            .drop();
    });
source

pub fn loop_( &mut self, ty: impl Into<InstrSeqType>, make_loop: impl FnOnce(&mut InstrSeqBuilder<'_>) ) -> &mut Self

Create a new loop ... end instruction sequence.

Example
let mut module = walrus::Module::default();
let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

// Append the following WAT to the function:
//
//     block
//       i32.const 1337
//       drop
//     end
builder
    .func_body()
    .loop_(None, |loop_| {
        loop_
            .i32_const(1337)
            .drop();
    });
source

pub fn loop_at( &mut self, position: usize, ty: impl Into<InstrSeqType>, make_loop: impl FnOnce(&mut InstrSeqBuilder<'_>) ) -> &mut Self

Splice a new loop ... end into this instruction sequence at the given position.

Example
let mut module = walrus::Module::default();
let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

// Make the function's body be a single `unreachable` instruction.
builder
    .func_body()
    .unreachable();

// Splice the following WAT into the function, before the `unreachable`:
//
//     loop
//       i32.const 1337
//       drop
//     end
builder
    .func_body()
    .loop_at(0, None, |loop_| {
        loop_
            .i32_const(1337)
            .drop();
    });
source

pub fn if_else( &mut self, ty: impl Into<InstrSeqType>, consequent: impl FnOnce(&mut InstrSeqBuilder<'_>), alternative: impl FnOnce(&mut InstrSeqBuilder<'_>) ) -> &mut Self

Build a new if <consequent> else <alternative> end instruction sequence.

Example
use walrus::ValType;

let mut module = walrus::Module::default();

let ty = module.types.add(&[], &[ValType::I32]);
let (flip_coin, _) = module.add_import_func("flip", "coin", ty);

let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);
builder
    .func_body()
    // (if (call $flip_coin)
    //   (then (i32.const 12))
    //   (else (i32.const 34)))
    .call(flip_coin)
    .if_else(
        ValType::I32,
        |then| {
            then.i32_const(12);
        },
        |else_| {
            else_.i32_const(34);
        },
    );
source

pub fn if_else_at( &mut self, position: usize, ty: impl Into<InstrSeqType>, consequent: impl FnOnce(&mut InstrSeqBuilder<'_>), alternative: impl FnOnce(&mut InstrSeqBuilder<'_>) ) -> &mut Self

Splice a new if <consequent> else <alternative> end into this instruction sequence at the given position.

Example
use walrus::ValType;

let mut module = walrus::Module::default();

let ty = module.types.add(&[], &[ValType::I32]);
let (flip_coin, _) = module.add_import_func("flip", "coin", ty);

let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

builder
    .func_body()
    .call(flip_coin)
    .unreachable();

// Splice an if/else after the `call` and before the `unreachable`.
builder
    .func_body()
    .if_else_at(
        1,
        ValType::I32,
        |then| {
            then.i32_const(12);
        },
        |else_| {
            else_.i32_const(34);
        },
    );
source§

impl InstrSeqBuilder<'_>

source

pub fn call(&mut self, func: FunctionId) -> &mut Self

Push a new Call instruction onto this builder’s block.

source

pub fn call_at(&mut self, position: usize, func: FunctionId) -> &mut Self

Splice a new Call instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn call_indirect(&mut self, ty: TypeId, table: TableId) -> &mut Self

Push a new CallIndirect instruction onto this builder’s block.

source

pub fn call_indirect_at( &mut self, position: usize, ty: TypeId, table: TableId ) -> &mut Self

Splice a new CallIndirect instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn local_get(&mut self, local: LocalId) -> &mut Self

Push a new LocalGet instruction onto this builder’s block.

source

pub fn local_get_at(&mut self, position: usize, local: LocalId) -> &mut Self

Splice a new LocalGet instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn local_set(&mut self, local: LocalId) -> &mut Self

Push a new LocalSet instruction onto this builder’s block.

source

pub fn local_set_at(&mut self, position: usize, local: LocalId) -> &mut Self

Splice a new LocalSet instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn local_tee(&mut self, local: LocalId) -> &mut Self

Push a new LocalTee instruction onto this builder’s block.

source

pub fn local_tee_at(&mut self, position: usize, local: LocalId) -> &mut Self

Splice a new LocalTee instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn global_get(&mut self, global: GlobalId) -> &mut Self

Push a new GlobalGet instruction onto this builder’s block.

source

pub fn global_get_at(&mut self, position: usize, global: GlobalId) -> &mut Self

Splice a new GlobalGet instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn global_set(&mut self, global: GlobalId) -> &mut Self

Push a new GlobalSet instruction onto this builder’s block.

source

pub fn global_set_at(&mut self, position: usize, global: GlobalId) -> &mut Self

Splice a new GlobalSet instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn const_(&mut self, value: Value) -> &mut Self

Push a new Const instruction onto this builder’s block.

source

pub fn const_at(&mut self, position: usize, value: Value) -> &mut Self

Splice a new Const instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn binop(&mut self, op: BinaryOp) -> &mut Self

Push a new Binop instruction onto this builder’s block.

source

pub fn binop_at(&mut self, position: usize, op: BinaryOp) -> &mut Self

Splice a new Binop instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn unop(&mut self, op: UnaryOp) -> &mut Self

Push a new Unop instruction onto this builder’s block.

source

pub fn unop_at(&mut self, position: usize, op: UnaryOp) -> &mut Self

Splice a new Unop instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn select(&mut self, ty: Option<ValType>) -> &mut Self

Push a new Select instruction onto this builder’s block.

source

pub fn select_at(&mut self, position: usize, ty: Option<ValType>) -> &mut Self

Splice a new Select instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn unreachable(&mut self) -> &mut Self

Push a new Unreachable instruction onto this builder’s block.

source

pub fn unreachable_at(&mut self, position: usize) -> &mut Self

Splice a new Unreachable instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn br(&mut self, block: InstrSeqId) -> &mut Self

Push a new Br instruction onto this builder’s block.

source

pub fn br_at(&mut self, position: usize, block: InstrSeqId) -> &mut Self

Splice a new Br instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn br_if(&mut self, block: InstrSeqId) -> &mut Self

Push a new BrIf instruction onto this builder’s block.

source

pub fn br_if_at(&mut self, position: usize, block: InstrSeqId) -> &mut Self

Splice a new BrIf instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn br_table( &mut self, blocks: Box<[InstrSeqId]>, default: InstrSeqId ) -> &mut Self

Push a new BrTable instruction onto this builder’s block.

source

pub fn br_table_at( &mut self, position: usize, blocks: Box<[InstrSeqId]>, default: InstrSeqId ) -> &mut Self

Splice a new BrTable instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn drop(&mut self) -> &mut Self

Push a new Drop instruction onto this builder’s block.

source

pub fn drop_at(&mut self, position: usize) -> &mut Self

Splice a new Drop instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn return_(&mut self) -> &mut Self

Push a new Return instruction onto this builder’s block.

source

pub fn return_at(&mut self, position: usize) -> &mut Self

Splice a new Return instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn memory_size(&mut self, memory: MemoryId) -> &mut Self

Push a new MemorySize instruction onto this builder’s block.

source

pub fn memory_size_at(&mut self, position: usize, memory: MemoryId) -> &mut Self

Splice a new MemorySize instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn memory_grow(&mut self, memory: MemoryId) -> &mut Self

Push a new MemoryGrow instruction onto this builder’s block.

source

pub fn memory_grow_at(&mut self, position: usize, memory: MemoryId) -> &mut Self

Splice a new MemoryGrow instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn memory_init(&mut self, memory: MemoryId, data: DataId) -> &mut Self

Push a new MemoryInit instruction onto this builder’s block.

source

pub fn memory_init_at( &mut self, position: usize, memory: MemoryId, data: DataId ) -> &mut Self

Splice a new MemoryInit instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn data_drop(&mut self, data: DataId) -> &mut Self

Push a new DataDrop instruction onto this builder’s block.

source

pub fn data_drop_at(&mut self, position: usize, data: DataId) -> &mut Self

Splice a new DataDrop instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn memory_copy(&mut self, src: MemoryId, dst: MemoryId) -> &mut Self

Push a new MemoryCopy instruction onto this builder’s block.

source

pub fn memory_copy_at( &mut self, position: usize, src: MemoryId, dst: MemoryId ) -> &mut Self

Splice a new MemoryCopy instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn memory_fill(&mut self, memory: MemoryId) -> &mut Self

Push a new MemoryFill instruction onto this builder’s block.

source

pub fn memory_fill_at(&mut self, position: usize, memory: MemoryId) -> &mut Self

Splice a new MemoryFill instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn load( &mut self, memory: MemoryId, kind: LoadKind, arg: MemArg ) -> &mut Self

Push a new Load instruction onto this builder’s block.

source

pub fn load_at( &mut self, position: usize, memory: MemoryId, kind: LoadKind, arg: MemArg ) -> &mut Self

Splice a new Load instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn store( &mut self, memory: MemoryId, kind: StoreKind, arg: MemArg ) -> &mut Self

Push a new Store instruction onto this builder’s block.

source

pub fn store_at( &mut self, position: usize, memory: MemoryId, kind: StoreKind, arg: MemArg ) -> &mut Self

Splice a new Store instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn atomic_rmw( &mut self, memory: MemoryId, op: AtomicOp, width: AtomicWidth, arg: MemArg ) -> &mut Self

Push a new AtomicRmw instruction onto this builder’s block.

source

pub fn atomic_rmw_at( &mut self, position: usize, memory: MemoryId, op: AtomicOp, width: AtomicWidth, arg: MemArg ) -> &mut Self

Splice a new AtomicRmw instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn cmpxchg( &mut self, memory: MemoryId, width: AtomicWidth, arg: MemArg ) -> &mut Self

Push a new Cmpxchg instruction onto this builder’s block.

source

pub fn cmpxchg_at( &mut self, position: usize, memory: MemoryId, width: AtomicWidth, arg: MemArg ) -> &mut Self

Splice a new Cmpxchg instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn atomic_notify(&mut self, memory: MemoryId, arg: MemArg) -> &mut Self

Push a new AtomicNotify instruction onto this builder’s block.

source

pub fn atomic_notify_at( &mut self, position: usize, memory: MemoryId, arg: MemArg ) -> &mut Self

Splice a new AtomicNotify instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn atomic_wait( &mut self, memory: MemoryId, arg: MemArg, sixty_four: bool ) -> &mut Self

Push a new AtomicWait instruction onto this builder’s block.

source

pub fn atomic_wait_at( &mut self, position: usize, memory: MemoryId, arg: MemArg, sixty_four: bool ) -> &mut Self

Splice a new AtomicWait instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn atomic_fence(&mut self) -> &mut Self

Push a new AtomicFence instruction onto this builder’s block.

source

pub fn atomic_fence_at(&mut self, position: usize) -> &mut Self

Splice a new AtomicFence instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_get(&mut self, table: TableId) -> &mut Self

Push a new TableGet instruction onto this builder’s block.

source

pub fn table_get_at(&mut self, position: usize, table: TableId) -> &mut Self

Splice a new TableGet instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_set(&mut self, table: TableId) -> &mut Self

Push a new TableSet instruction onto this builder’s block.

source

pub fn table_set_at(&mut self, position: usize, table: TableId) -> &mut Self

Splice a new TableSet instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_grow(&mut self, table: TableId) -> &mut Self

Push a new TableGrow instruction onto this builder’s block.

source

pub fn table_grow_at(&mut self, position: usize, table: TableId) -> &mut Self

Splice a new TableGrow instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_size(&mut self, table: TableId) -> &mut Self

Push a new TableSize instruction onto this builder’s block.

source

pub fn table_size_at(&mut self, position: usize, table: TableId) -> &mut Self

Splice a new TableSize instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_fill(&mut self, table: TableId) -> &mut Self

Push a new TableFill instruction onto this builder’s block.

source

pub fn table_fill_at(&mut self, position: usize, table: TableId) -> &mut Self

Splice a new TableFill instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn ref_null(&mut self, ty: ValType) -> &mut Self

Push a new RefNull instruction onto this builder’s block.

source

pub fn ref_null_at(&mut self, position: usize, ty: ValType) -> &mut Self

Splice a new RefNull instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn ref_is_null(&mut self) -> &mut Self

Push a new RefIsNull instruction onto this builder’s block.

source

pub fn ref_is_null_at(&mut self, position: usize) -> &mut Self

Splice a new RefIsNull instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn ref_func(&mut self, func: FunctionId) -> &mut Self

Push a new RefFunc instruction onto this builder’s block.

source

pub fn ref_func_at(&mut self, position: usize, func: FunctionId) -> &mut Self

Splice a new RefFunc instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn v128_bitselect(&mut self) -> &mut Self

Push a new V128Bitselect instruction onto this builder’s block.

source

pub fn v128_bitselect_at(&mut self, position: usize) -> &mut Self

Splice a new V128Bitselect instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn i8x16_swizzle(&mut self) -> &mut Self

Push a new I8x16Swizzle instruction onto this builder’s block.

source

pub fn i8x16_swizzle_at(&mut self, position: usize) -> &mut Self

Splice a new I8x16Swizzle instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn i8x16_shuffle(&mut self, indices: ShuffleIndices) -> &mut Self

Push a new I8x16Shuffle instruction onto this builder’s block.

source

pub fn i8x16_shuffle_at( &mut self, position: usize, indices: ShuffleIndices ) -> &mut Self

Splice a new I8x16Shuffle instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn load_simd( &mut self, memory: MemoryId, kind: LoadSimdKind, arg: MemArg ) -> &mut Self

Push a new LoadSimd instruction onto this builder’s block.

source

pub fn load_simd_at( &mut self, position: usize, memory: MemoryId, kind: LoadSimdKind, arg: MemArg ) -> &mut Self

Splice a new LoadSimd instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_init(&mut self, table: TableId, elem: ElementId) -> &mut Self

Push a new TableInit instruction onto this builder’s block.

source

pub fn table_init_at( &mut self, position: usize, table: TableId, elem: ElementId ) -> &mut Self

Splice a new TableInit instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn elem_drop(&mut self, elem: ElementId) -> &mut Self

Push a new ElemDrop instruction onto this builder’s block.

source

pub fn elem_drop_at(&mut self, position: usize, elem: ElementId) -> &mut Self

Splice a new ElemDrop instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

source

pub fn table_copy(&mut self, src: TableId, dst: TableId) -> &mut Self

Push a new TableCopy instruction onto this builder’s block.

source

pub fn table_copy_at( &mut self, position: usize, src: TableId, dst: TableId ) -> &mut Self

Splice a new TableCopy instruction into this builder’s block at the given index.

Panics

Panics if position > self.instrs.len().

Methods from Deref<Target = FunctionBuilder>§

source

pub fn name(&mut self, function_name: String) -> &mut FunctionBuilder

Set function name.

source

pub fn func_body_id(&self) -> InstrSeqId

Get the id of this function’s body’s instruction sequence.

source

pub fn func_body(&mut self) -> InstrSeqBuilder<'_>

Get a InstrSeqBuilder for building and mutating this function’s body.

source

pub fn instr_seq(&mut self, id: InstrSeqId) -> InstrSeqBuilder<'_>

Continue building and mutating an existing instruction sequence.

Example
let mut module = walrus::Module::default();
let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

let mut block = builder.dangling_instr_seq(None);
let id = block.id();
// Build up the block some.
block
    .f64_const(1337.0)
    .drop();

// Do some other stuff...
drop(block);

// Use `instr_seq` to get the builder for the block again, and build
// some more things onto it.
let mut block = builder.instr_seq(id);
block
    .i32_const(42)
    .drop();
source

pub fn dangling_instr_seq( &mut self, ty: impl Into<InstrSeqType> ) -> InstrSeqBuilder<'_>

Create a new instruction sequence that is unreachable.

It is your responsibility to

  • make a Instr::Block, Instr::Loop, or Instr::IfElse that uses this instruction sequence, and

  • append that Instr into a parent instruction sequence via InstrSeqBuilder::instr or InstrSeqBuilder::instr_at

or else this built up instruction sequence will never be used.

Example
use walrus::ir::*;

let mut module = walrus::Module::default();
let mut builder = walrus::FunctionBuilder::new(&mut module.types, &[], &[]);

// Create an empty, dangling instruction sequemce.
let mut seq = builder.dangling_instr_seq(None);
let seq_id = seq.id();

// Do stuff with the sequence...
drop(seq);

// Finally, make our instruction sequence reachable by adding an
// block/loop/if-else instruction that uses it to a reachable instruction
// sequence.
builder
    .func_body()
    .instr(Block { seq: seq_id });

Trait Implementations§

source§

impl<'a> Debug for InstrSeqBuilder<'a>

source§

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

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

impl Deref for InstrSeqBuilder<'_>

§

type Target = FunctionBuilder

The resulting type after dereferencing.
source§

fn deref(&self) -> &FunctionBuilder

Dereferences the value.
source§

impl DerefMut for InstrSeqBuilder<'_>

source§

fn deref_mut(&mut self) -> &mut FunctionBuilder

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for InstrSeqBuilder<'a>

§

impl<'a> Send for InstrSeqBuilder<'a>

§

impl<'a> Sync for InstrSeqBuilder<'a>

§

impl<'a> Unpin for InstrSeqBuilder<'a>

§

impl<'a> !UnwindSafe for InstrSeqBuilder<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.