Ferrous API Reference

All Types / Ferrous.Guard

struct ScopeGuard<TState> [MustUse]

public ref struct ScopeGuard<TState> : IDisposable

A stack-allocated scope guard carrying explicit TState to avoid closure allocations.

Type Parameters
TState
The type of state forwarded to the cleanup callback.

Properties

public readonly bool IsActive

Gets a value indicating whether this guard is still active and will run on disposal.

Methods

public void Dismiss()

Disarms the guard so that disposing it becomes a no-op.

public void Dispose()

Executes the deferred callback with the captured state if the guard has not been dismissed or already disposed.