See More

A very common reason is a wrong site baseUrl configuration.\n

Current configured baseUrl = / (default value)\n

We suggest trying baseUrl = \n\n',document.body.prepend(n);var e=document.getElementById("__docusaurus-base-url-issue-banner-suggestion-container"),s=window.location.pathname,o="/"===s.substr(-1)?s:s+"/";e.textContent=o}document.addEventListener("DOMContentLoaded",function(){void 0===window.docusaurus&&insertBanner()})

Skip to main content

Getting Started

ZeroAlloc.Results is a zero-allocation Result<T, E> library for .NET 9. Every type is a readonly struct — no heap allocation on any code path, no GC pressure, no boxing.

Installation

dotnet add package ZeroAlloc.Results

Your First Pipeline

using ZeroAlloc.Results;
using ZeroAlloc.Results.Extensions;

// 1. Create results
Result<int, string> success = Result<int, string>.Success(42);
Result<int, string> failure = Result<int, string>.Failure("not found");

// 2. Implicit conversion
Result<int, string> r = 42; // success
Result<int, string> e = "error"; // failure

// 3. Chain operations
var result = GetUserId(input)
.Ensure(id => id > 0, "id must be positive")
.Bind(id => LoadUser(id))
.Map(user => user.Email);

// 4. Extract with Match
string message = result.Match(
onSuccess: email => $"User email: {email}",
onFailure: err => $"Error: {err}");

Choosing a Type

ScenarioType
Simple pass/fail with a messageResult
Operation returns a value or a string errorResult<T>
Operation returns a value or a typed errorResult<T, E>
Operation succeeds (no value) or fails with typed errorUnitResult<E>
Value that may or may not be presentMaybe<T>

Next Steps

  • Types — full reference for all five types
  • Combinators — Map, Bind, Match, Tap, Ensure, Combine
  • Async — ValueTask async pipelines
  • LINQ — query syntax support