diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2025-01-04 15:08:53 +0100 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2025-01-04 15:08:53 +0100 |
| commit | 807a25b638e38d7c0446bb728412fb16fd035035 (patch) | |
| tree | 4cfcb99bd00857ca3296b6dbb259976dcaaae689 /options/options.go | |
| download | go-gg-807a25b638e38d7c0446bb728412fb16fd035035.tar.gz | |
init
Diffstat (limited to 'options/options.go')
| -rw-r--r-- | options/options.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/options/options.go b/options/options.go new file mode 100644 index 0000000..e058559 --- /dev/null +++ b/options/options.go @@ -0,0 +1,22 @@ +/******************************************************************************* +* Copyright 2025 Stefan Majewsky <majewsky@gmx.net> +* SPDX-License-Identifier: Apache-2.0 +* Refer to the file "LICENSE" for details. +*******************************************************************************/ + +// Package options provides additional functions for type option.Option +// that cannot be expressed as methods on the Option type itself. +package options + +import . "github.com/majewsky/gg/option" + +// NOTE: Keep functions sorted by name. + +// FromPointer converts a *T into an Option[T]. +func FromPointer[T any](value *T) Option[T] { + if value == nil { + return None[T]() + } else { + return Some(*value) + } +} |
