Unio 0.7.12
Requires NuGet 2.12 or higher.
dotnet add package Unio --version 0.7.12
NuGet\Install-Package Unio -Version 0.7.12
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unio" Version="0.7.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unio" Version="0.7.12" />
<PackageReference Include="Unio" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Unio --version 0.7.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Unio, 0.7.12"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Unio@0.7.12
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Unio&version=0.7.12
#tool nuget:?package=Unio&version=0.7.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Unio
High-performance discriminated unions for C#. Designed with strongly typed generic fields, full value equality semantics and allocation-free pattern matching for maximum performance and type safety.
Usage
using Unio;
// Implicit conversion
Unio<int, string> result = 42;
Unio<int, string> error = "not found";
// Exhaustive matching
string text = result.Match(
i => $"Number: {i}",
s => $"Text: {s}");
// Allocation-free matching - pass state instead of capturing variables
// (no closure object allocated per call)
string prefix = "Result";
string text2 = result.Match(prefix,
static (p, i) => $"{p}: {i}",
static (p, s) => $"{p}: {s}");
// Allocation-free side-effect switch
result.Switch((prefix, Console.Out),
static (s, i) => s.Out.WriteLine($"{s.prefix}: {i}"),
static (s, str) => s.Out.WriteLine($"{s.prefix}: {str}"));
// Safe TryGet pattern
if (result.TryGetT0(out int number))
Console.WriteLine(number);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Unio:
| Package | Downloads |
|---|---|
|
Unio.AspNetCore
Unio provides high-performance, struct-based discriminated unions for C#. Zero-allocation, exhaustive matching, Match, Switch and TryGet patterns and full value semantics. Simple, performant and scalable. |
GitHub repositories
This package is not used by any popular GitHub repositories.