Documentation
¶
Index ¶
- type Result
- func (r Result[T]) Fill(v T) Result[T]
- func (r Result[T]) FillErr(err error) Result[T]
- func (r Result[T]) FillTuple(v T, err error) Result[T]
- func (r Result[T]) IsErr() bool
- func (r Result[T]) IsOk() bool
- func (r Result[T]) String() string
- func (r Result[T]) Tuple() (T, error)
- func (r Result[T]) TupleBool() (T, bool)
- func (r Result[T]) Unwrap() T
- func (r Result[T]) UnwrapErr() error
- func (r Result[T]) UnwrapOr(or T) T
- func (r Result[T]) Zero() Result[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Result[T] is a type that can be used to return a value or an error. It is similar to Rust's Result<T, E> type. Result[T] occupies a fixed size of 3 words. For most common types, Result[T] needs no heap allocation.
func (Result[T]) FillErr ¶ added in v0.2.0
FillErr returns a new Result[T] that contains the given error.
func (Result[T]) FillTuple ¶ added in v0.2.0
FillTuple returns a new Result[T] that contains the given value or error.
func (Result[T]) TupleBool ¶
TupleBool returns the value and a boolean indicating whether the Result[T] is ok.
func (Result[T]) Unwrap ¶
func (r Result[T]) Unwrap() T
Unwrap returns the value contained in the Result[T].
Click to show internal directories.
Click to hide internal directories.