AI Decision System
Replayable, offline-verifiable records for AI-assisted go/no-go decisions: experiment promotions, typed model answers and human-approved actions.
翻譯準備中
Zero-allocation, no-boxing Result<T,E> library for .NET 9 with full CSharpFunctionalExtensions API parity.
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗Railway-style Result<T, E> for .NET 8, 9 and 10: errors as values instead of exceptions, 0 B allocated on success and failure alike, NativeAOT-ready.
readonly struct. Allocation tests assert 0 B for Map, Bind, Match, Tap, Ensure, Combine and LINQ query syntax, for success and failure, and for the ValueTask combinators when they complete synchronously.Map, Bind, Match, Tap and Ensure, LINQ query syntax and ValueTask async variants. Coming from CSharpFunctionalExtensions, most code moves over by swapping the using.dotnet add package ZeroAlloc.Results
using ZeroAlloc.Results;
using ZeroAlloc.Results.Extensions;
Console.WriteLine(Describe("42")); // Welcome, age 42
Console.WriteLine(Describe("12")); // Rejected: too young
Console.WriteLine(Describe("abc")); // Rejected: not a number
static string Describe(string input) =>
ParseAge(input)
.Ensure(static age => age >= 18, "too young")
.Map(static age => $"Welcome, age {age}")
.Match(static text => text, static error => $"Rejected: {error}");
// A value converts to success, an error converts to failure.
static Result<int, string> ParseAge(string input) =>
int.TryParse(input, out var age) ? age : "not a number";
No exception is thrown: the first failure skips the remaining steps and lands in Match.
Maybe<T>).if checks.from … in … select.ValueTask-based variants, plus Map and Bind that continue straight onto a ValueTask<Result<T, E>>..NET 10.0.13, BenchmarkDotNet v0.15.8, all libraries in the same run. Allocations are exact; time is the ratio against ZeroAlloc.Results.
| Scenario | ZeroAlloc.Results | OneOf | ErrorOr | FluentResults |
|---|---|---|---|---|
| Failure construct | 0 B | 0 B | 88 B | 272 B |
| Failure consume | 0 B | 0 B | 0 B | 240 B |
| Hot loop (100 iter, 1-in-3 fail), time | 1.00 | 1.02 | 4.14 | 41.4 |
| Hot loop, allocated | 0 B | 0 B | 2,992 B | 25,968 B |
The performance page has every scenario, a comparison with CSharpFunctionalExtensions, a Result versus throw/catch benchmark and how to run them yourself.
Result<T, E> instead of throwing.Result<T, ValidationError>.UnitResult<AuthorizationFailure>.