Ferrous API Reference

All Types / Ferrous.Results

struct NonZero<T> [NoDefault]

public readonly struct NonZero<T> : IEquatable<NonZero<T>>, IComparable<NonZero<T>> where T : struct, INumberBase<T>, IComparable<T>

A zero-allocation wrapper guaranteeing a non-zero numeric value (Rust's std::num::NonZero<T>).

Type Parameters
T
A numeric value type implementing INumberBase<TSelf>.

Properties

public T Value

Gets the guaranteed non-zero underlying value.

Exceptions
InvalidOperationException
Thrown if default-initialized.

Methods

public static Option<NonZero<T>> TryCreate(T value)

Creates a NonZero<T> if value is non-zero; otherwise Option<T>.None.

public bool Equals(NonZero<T> other)
public override bool Equals(object? obj)
public override int GetHashCode()
public int CompareTo(NonZero<T> other)
public override string ToString()