github.com/primecitizens/pcz/std@v0.2.1/core/opt/opt.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package opt 5 6 // Interface defines required methods for an optional value. 7 type Interface[Value any] interface { 8 // Set the value. 9 Set(Value) 10 11 // Get the value, IsNone() MUST be checked before calling this method 12 Get() Value 13 14 // Erase the existing value and returns true if there was value. 15 // 16 // After calling this, IsNone() will return true until Set(T) is called. 17 Erase() (hadValue bool) 18 19 // IsNone returns true if there is no value set. 20 IsNone() bool 21 22 // IsSome returns true if there is value set. 23 IsSome() bool 24 }