aboutsummaryrefslogtreecommitdiff
path: root/options/options.go
blob: e058559c9477fb9ced0a84a85079a2ed7e457094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
	}
}