Skip to main content

Result

Type Alias Result 

Source
pub type Result<T> = Result<T, Error>;
Expand description

Result type alias using Error as the error type.

This is the standard result type for all SDK and contract functions.

§Example

fn transfer(to: AccountId, amount: u64) -> Result<()> {
    if amount == 0 {
        return Err(Error::new(ERR_INVALID_AMOUNT));
    }
    // ... perform transfer
    Ok(())
}

Aliased Type§

pub enum Result<T> {
    Ok(T),
    Err(Error),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(Error)

Contains the error value