std1.0.0-beta-7 SafeC docs

std :: result

Struct std::Result

#include <std/result.h> source

generic<T, E> struct Result {
    T value;
    E error;
    int is_ok;
}

Fields

§T valuesource

valid when is_ok == 1

§E errorsource

valid when is_ok == 0

§int is_oksource

Methods

§static struct Result<T, E> new_ok(T val)source · definition

(ok/err are the queries below)

§static struct Result<T, E> new_err(E err)source · definition
§int ok() constsource · definition
§int err() constsource · definition
§?&T get_ok()source · definition

null for an error result

§?&E get_err()source · definition

null for an ok result

§T unwrap_or(T fallback) consumesource · definition

the value, or 'fallback' (the other one is dropped)

§T unwrap() consumesource · definition

the value; panics for an error result

§E unwrap_err() consumesource · definition

the error; panics for an ok result

§void drop() if (needs_drop(T) || needs_drop(E))source · definition