import "github.com/avivatedgi/go-rust-std/option"
func MapOr[T any, U any](option Option[T], other U, f func(*T) U) U
Returns the provided default result (if none)\, or applies a function to the contained value (if any). This function is not a method of option because method must have no type parameter. https://github.com/golang/go/issues/48793
func MapOrElse[T any, U any](option Option[T], def func() U, f func(*T) U) U
Computes a default function result (if none)\, or applies a different function to the contained value (if any). This function is not a method of option because method must have no type parameter. https://github.com/golang/go/issues/48793
This Option implementation is based on the one in the Rust’s standart library (https://doc.rust-lang.org/std/option/enum.Option.html) The Option represents an optional value: every Option is either Some and contains a value\, or None\, and does not.
type Option[T any] struct {
// contains filtered or unexported fields
}
func Map[T any, U any](option Option[T], f func(*T) U) Option[U]
Maps an Option[T] to Option[U] by applying a function to a contained value. This function is not a method of option because method must have no type parameter. https://github.com/golang/go/issues/48793
func None[T any]() Option[T]
Return an Option containing no value.
func Some[T any](value T) Option[T]
Return an Option containing the value `value`.
func (option Option[T]) Expect(message string) T
Returns the contained Some value\, consuming the option value. Panics if the value is a None with a custom panic message provided by message.
func (option Option[T]) IsNone() bool
Returns true if the option is a None value.
func (option Option[T]) IsSome() bool
Returns true if the option is a Some value.
func (option Option[T]) IsSomeWith(f func(*T) bool) bool
Returns true if the option is a Some wrapping a value matching the predicate.
func (option Option[T]) Unwrap() T
Returns the contained Some value\, consuming the option value. Because this function may panic\, its use is generally discouraged. Instead\, prefer to use pattern matching and handle the None case explicitly\, or call UnwrapOr\, UnwrapOrElse\, or UnwrapOrDefault. Panics if the self value equals None.
func (option Option[T]) UnwrapOr(other T) T
Returns the contained Some value or a provided default.
func (option Option[T]) UnwrapOrDefault() T
Returns the contained Some value or a default. Consumes the self argument then\, if Some\, returns the contained value\, otherwise if None\, returns the default value for that type.
func (option Option[T]) UnwrapOrElse(f func() T) T
Returns the contained Some value or computes it from a closure.
Generated by gomarkdoc