Class MoveOption<T>

Type Parameters

Hierarchy

Implements

Constructors

Properties

value?: T
vec: MoveVector<T>

Methods

  • Retrieves the inner value of the MoveOption.

    This method is inspired by Rust's Option<T>.unwrap(). In Rust, attempting to unwrap a None value results in a panic.

    Similarly, this method will throw an error if the value is not present.

    Returns T

    The contained value if present.

    Example

    const option = new MoveOption<Bool>(new Bool(true));
    const value = option.unwrap(); // Returns the Bool instance

    Throws

    Throws an error if the MoveOption does not contain a value.

  • Factory method to generate a MoveOption from a boolean or undefined.

    Parameters

    • Optional value: null | boolean

    Returns MoveOption<Bool>

    a MoveOption with an inner value value

    Example

    MoveOption.Bool(true).isSome() === true;
    MoveOption.Bool().isSome() === false;
    MoveOption.Bool(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a string or undefined.

    Parameters

    • Optional value: null | string

    Returns MoveOption<MoveString>

    a MoveOption with an inner value value

    Example

    MoveOption.MoveString("hello").isSome() === true;
    MoveOption.MoveString("").isSome() === true;
    MoveOption.MoveString().isSome() === false;
    MoveOption.MoveString(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or a bigint or undefined.

    Parameters

    Returns MoveOption<U128>

    a MoveOption with an inner value value

    Example

    MoveOption.U128(1).isSome() === true;
    MoveOption.U128().isSome() === false;
    MoveOption.U128(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or undefined.

    Parameters

    • Optional value: null | number

    Returns MoveOption<U16>

    a MoveOption with an inner value value

    Example

    MoveOption.U16(1).isSome() === true;
    MoveOption.U16().isSome() === false;
    MoveOption.U16(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or a bigint or undefined.

    Parameters

    Returns MoveOption<U256>

    a MoveOption with an inner value value

    Example

    MoveOption.U256(1).isSome() === true;
    MoveOption.U256().isSome() === false;
    MoveOption.U256(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or undefined.

    Parameters

    • Optional value: null | number

    Returns MoveOption<U32>

    a MoveOption with an inner value value

    Example

    MoveOption.U32(1).isSome() === true;
    MoveOption.U32().isSome() === false;
    MoveOption.U32(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or a bigint or undefined.

    Parameters

    Returns MoveOption<U64>

    a MoveOption with an inner value value

    Example

    MoveOption.U64(1).isSome() === true;
    MoveOption.U64().isSome() === false;
    MoveOption.U64(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or undefined.

    Parameters

    • Optional value: null | number

    Returns MoveOption<U8>

    a MoveOption with an inner value value

    Example

    MoveOption.U8(1).isSome() === true;
    MoveOption.U8().isSome() === false;
    MoveOption.U8(undefined).isSome() === false;

    Params

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

Generated using TypeDoc