Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
An Option is the structural representation of the common tuple API that signifies the presence, or lack thereof, of a value.
For example, let's say we have this simple getter method:
func Get(data map[string]string, key string) (string, bool) {
value, ok := data[key]
return value, ok
}
Although quite trivial, this could be rewritten to leverage the Option type like so:
func Get(data map[string]string, key string) Option[string] {
if value, ok := data[key]; ok {
return Some(value)
}
return None[string]()
}
func None ¶
None returns an Option value which represents a "None" variant for the inner type.
Options generated with this constructor will always return `false` for calls to `IsSome`, and `true` for calls to `IsNone`.
func Some ¶
Some returns an Option value which wraps the provided value as a "Some" variant.
Options generated with this constructor will always return `true` for calls to `IsSome`, and `false` for calls to `IsNone`.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package iter provides...
|
Package iter provides... |
|
Package iterator provides the Iterator type which exposes an easily chainable, struct variant of the functional iterator API provided by the iter module.
|
Package iterator provides the Iterator type which exposes an easily chainable, struct variant of the functional iterator API provided by the iter module. |
|
Package math provides various mathematical utilities to work with other oxide types.
|
Package math provides various mathematical utilities to work with other oxide types. |