DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.0.0-beta.9" />

.NET API 420,824 bytes

 Consumer<T>

public struct Consumer<T> : IConsumer<T>
Represents typed function pointer implementing IConsumer<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 Consumer<[System.Runtime.CompilerServices.Nullable(2)] T> : IConsumer<T> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] private readonly IntPtr ptr; public unsafe bool IsEmpty => ptr == (IntPtr)(void*)null; public unsafe Consumer([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] IntPtr ptr) { if (ptr == (IntPtr)(void*)null) throw new ArgumentNullException("ptr"); this.ptr = ptr; } void IConsumer<T>.Invoke(T arg) { IntPtr intPtr = ptr; ; } public Action<T> ToDelegate() { return DelegateHelpers.CreateDelegate<T>(ptr); } public unsafe override string ToString() { return new IntPtr((void*)(long)ptr).ToString("X"); } public static implicit operator Consumer<T>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] IntPtr ptr) { return new Consumer<T>(ptr); } public static explicit operator Action<T>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] Consumer<T> consumer) { return consumer.ToDelegate(); } } }