Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Failure ¶ added in v0.0.2
type Failure[T any] struct { // contains filtered or unexported fields }
Failure struct represents a failed outcome wrapping an error within a Result container.
type None ¶
type None[T any] struct{}
None represents an Optional instance that does not contain any value.
func (*None[T]) Get ¶
func (n *None[T]) Get() T
Get always returns the zero value of type T since None contains no value.
type Optional ¶
type Optional[T any] interface { // IsPresent returns true if there is a value present, otherwise false. IsPresent() bool // IsEmpty returns true if there is no value present, otherwise false. IsEmpty() bool // Get returns the value if present. If no value is present, it returns the zero value of type T. Get() T }
Optional represents a container object which may or may not contain a non-nil value. It provides a type-safe alternative to using nil pointers.
type Result ¶ added in v0.0.2
type Result[T any] interface { // IsSuccess returns true if the operation completed successfully, otherwise false. IsSuccess() bool // IsFailure returns true if the operation failed with an error, otherwise false. IsFailure() bool // Value returns the success value if present, or the zero value of type T. Value() T // Error returns the underlying error if it failed, or nil. Error() error }
Result represents the outcome of an operation that can either succeed with a value of type T or fail with an error. It wraps the standard built-in error type.
func NewFailure ¶ added in v0.0.2
NewFailure creates and returns a new failed Result containing the provided error.
func NewSuccess ¶ added in v0.0.2
NewSuccess creates and returns a new successful Result containing the provided value.
type Some ¶
type Some[T any] struct { // contains filtered or unexported fields }
Some represents an Optional instance that contains a value.
func (*Some[T]) Get ¶
func (s *Some[T]) Get() T
Get returns the underlying value. If the receiver is nil, it returns the zero value of type T.
type Success ¶ added in v0.0.2
type Success[T any] struct { // contains filtered or unexported fields }
Success struct represents a successful outcome within a Result container.