Discover Packages
goforge.dev/gpp/std
option
package
Version:
v0.14.0
Opens a new window with list of versions in this module.
Published: Jul 20, 2026
License: MIT
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package option is the presence type of G++: a value that is there
(Some) or absent (None). It is authored in G++ and distributed as
generated Go — consumers never need the gpp toolchain.
Fold reduces Option[T] by one-level case analysis.
Get leaves in Go's comma-ok shape.
func UnwrapOr[T any ](o Option [T], fallback T) T
UnwrapOr yields the value or a fallback.
type None[T any ] struct{}
type Option[T any ] interface {
}
Option carries at most one value.
Bind chains an option-producing function; None bypasses it.
Map lifts a plain function over the value; None passes through.
Of enters from Go's comma-ok shape.
OrElse yields the option itself when present, otherwise the
alternative.
type OptionCases[T any , R any ] struct {
Some func(value T) R
None func() R
}
OptionCases selects one handler per Option variant for Fold.
type Some[T any ] struct {
Value T
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.