A null-free optional value library for .NET with an emphasis on minimizing additional allocations.
- An optional value is represented as the struct Opt<T>
- A possible value or error is represented as the struct Result<T, E>
- A zero to N values are represented as the struct Any<T>
See the Examples Tests for more on how to use Opt.
- NuGet packages are available on NuGet.org
- Embedded debug symbols
- Source Link enabled
- NuGet packages from CI builds are available on the libanvl GitHub feed
- Immutable
- Use Opt<T> instead of T? for optional values
- Implicit conversion from T to Opt<T>
- Deep selection of properties in complex objects
- SomeOrDefault() for any type
- Explicitly opt-in to exceptions with Unwrap()
- Cast inner value to compatible type with Cast<U>()
- Opts of IEnumerable<T> are iterable
- Create success results with Result.Ok
- Create error results with Result.Err
- Unwrap values with Unwrap, throwing if the result is an error
- Match on success or error with Match
- Convert between Opt and Result
- OneOrMany<T> for a single value or a collection of values
- Implicit conversions
- Equality operators
- Any<T> for a single value or multiple values
- Implicit conversions
- Equality operators
- Add and remove elements
- Convert to array, list, or enumerable
- Convert to Opt<T>
- Cast elements to a compatible type
- Dictionary-like collection that maps keys to values of type Any<V>
- Implements IAnyRefMap<K, V> for reference-based operations
- Get or add value by reference with GetOrAddValueRef
- Get value by reference with GetValueRef
- Try to get value by reference with TryGetValueRef
- Perform actions on each reference with ForEachRef
- Enumerate references with GetEnumerator