DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.1.0" />

.NET API 437,208 bytes

 Supplier<TResult>

public struct Supplier<TResult> : ISupplier<TResult>
Represents typed function pointer implementing ISupplier<T>.
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace DotNext { [StructLayout(LayoutKind.Auto)] [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] [CLSCompliant(false)] public readonly struct Supplier<[System.Runtime.CompilerServices.Nullable(2)] TResult> : ISupplier<TResult> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] private readonly IntPtr ptr; public unsafe bool IsEmpty => ptr == (IntPtr)(void*)null; public unsafe Supplier([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] IntPtr ptr) { if (ptr == (IntPtr)(void*)null) throw new ArgumentNullException("ptr"); this.ptr = ptr; } TResult ISupplier<TResult>.Invoke() { return (TResult); } public Func<TResult> ToDelegate() { return DelegateHelpers.CreateDelegate<TResult>(ptr); } public unsafe override string ToString() { return new IntPtr((void*)(long)ptr).ToString("X"); } public static implicit operator Supplier<TResult>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] IntPtr ptr) { return new Supplier<TResult>(ptr); } public static explicit operator Func<TResult>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] Supplier<TResult> supplier) { return supplier.ToDelegate(); } } }