DotNext by .NET Foundation and Contributors

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

.NET API 523,352 bytes

 Supplier<TResult>

public struct Supplier<TResult> : ISupplier<TResult>, IFunctional<Func<TResult>>
Represents typed function pointer implementing ISupplier<T>.
using DotNext.Runtime.CompilerServices; using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace DotNext { [StructLayout(LayoutKind.Auto)] [NullableContext(1)] [Nullable(0)] [CLSCompliant(false)] public readonly struct Supplier<[Nullable(2)] TResult> : ISupplier<TResult>, IFunctional<Func<TResult>> { private readonly IntPtr ptr; public unsafe bool IsEmpty => ptr == (IntPtr)(void*)null; public unsafe Supplier([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>([Nullable(new byte[] { 0, 1 })] IntPtr ptr) { return new Supplier<TResult>(ptr); } public static explicit operator Func<TResult>([Nullable(new byte[] { 0, 1 })] Supplier<TResult> supplier) { return supplier.ToDelegate(); } } }