Module 0x1::result
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
- Enum
Result - Constants
- Function
test_variant$Result$Ok - Function
test_variant$Result$Err - Function
pack$Result$Ok - Function
pack$Result$Err - Function
unpack$Result$Ok - Function
unpack$Result$Err - Function
borrow$Result$0$0 - Function
borrow$Result$0$1 - Function
borrow_mut$Result$0$0 - Function
borrow_mut$Result$0$1 - Function
is_ok - Function
is_err - Function
unwrap - Function
unwrap_err - Function
map - Function
map_err - Function
and_then - Function
or_else
use 0x1::error;
Enum Result
Represents the result of some computation, either a value T or an error E.
enum Result<T, E> has copy, store
Variants
Ok
Fields
-
0: T
Err
Fields
-
0: E
Constants
Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
Function test_variant$Result$Ok
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun test_variant$Result$Ok()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function test_variant$Result$Err
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun test_variant$Result$Err()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function pack$Result$Ok
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun pack$Result$Ok()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function pack$Result$Err
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun pack$Result$Err()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function unpack$Result$Ok
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun unpack$Result$Ok()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function unpack$Result$Err
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun unpack$Result$Err()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function borrow$Result$0$0
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun borrow$Result$0$0()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function borrow$Result$0$1
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun borrow$Result$0$1()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function borrow_mut$Result$0$0
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun borrow_mut$Result$0$0()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function borrow_mut$Result$0$1
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
public fun borrow_mut$Result$0$1()
Implementation
module std::result {
use std::error;
/// Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;
/// Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;
/// Represents the result of some computation, either a value `T` or an error `E`.
public enum Result<T, E> has copy, store {
Ok(T),
Err(E)
}
/// Checks whether the result is Ok.
public fun is_ok<T, E>(self: &Result<T, E>): bool {
self is Ok
}
/// Checks whether the result is Err.
public fun is_err<T, E>(self: &Result<T, E>): bool {
self is Err
}
/// Unpacks the `T` of Ok or aborts.
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
/// Unpacks the `E` of Err or aborts.
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
/// Maps a `T` if it is available.
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
/// Maps a `E` if it is available.
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
/// Continues a `T` if it is available.
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
/// Tries an alternative if not Ok.
public inline fun or_else<T, E>(self: Result<T, E>, f: |E|Result<T, E>): Result<T, E> {
match (self) {
Err(e) => f(e),
ok => ok
}
}
}
Function is_ok
Checks whether the result is Ok.
public fun is_ok<T, E>(self: &result::Result<T, E>): bool
Function is_err
Checks whether the result is Err.
public fun is_err<T, E>(self: &result::Result<T, E>): bool
Function unwrap
Unpacks the T of Ok or aborts.
public fun unwrap<T, E>(self: result::Result<T, E>): T
Implementation
public fun unwrap<T, E>(self: Result<T, E>): T {
match (self) {
Ok(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_OK)
}
}
Function unwrap_err
Unpacks the E of Err or aborts.
public fun unwrap_err<T, E>(self: result::Result<T, E>): E
Implementation
public fun unwrap_err<T, E>(self: Result<T, E>): E {
match (self) {
Err(x) => x,
_ => abort error::invalid_argument(E_UNWRAP_ERR)
}
}
Function map
Maps a T if it is available.
public fun map<T, E, TNew>(self: result::Result<T, E>, f: |T|TNew): result::Result<TNew, E>
Implementation
public inline fun map<T, E, TNew>(self: Result<T, E>, f: |T|TNew): Result<TNew, E> {
match (self) {
Ok(x) => Result::Ok(f(x)),
Err(e) => Result::Err(e)
}
}
Function map_err
Maps a E if it is available.
public fun map_err<T, E, ENew>(self: result::Result<T, E>, f: |E|ENew): result::Result<T, ENew>
Implementation
public inline fun map_err<T, E, ENew>(self: Result<T, E>, f: |E|ENew): Result<T, ENew> {
match (self) {
Ok(x) => Result::Ok(x),
Err(e) => Result::Err(f(e))
}
}
Function and_then
Continues a T if it is available.
public fun and_then<T, E, TNew>(self: result::Result<T, E>, f: |T|result::Result<TNew, E>): result::Result<TNew, E>
Implementation
public inline fun and_then<T, E, TNew>(self: Result<T, E>, f: |T|Result<TNew, E>): Result<TNew, E> {
match (self) {
Ok(x) => f(x),
Err(e) => Result::Err(e)
}
}
Function or_else
Tries an alternative if not Ok.
public fun or_else<T, E>(self: result::Result<T, E>, f: |E|result::Result<T, E>): result::Result<T, E>