using System.Runtime.CompilerServices; namespace FloppyUtils; public static unsafe class RefPtr { public static RefPtr For(ref T at) where T : unmanaged { return new() { Ref = ref at }; } } public unsafe ref struct RefPtr where TAt : unmanaged { public ref TAt Ref; public TAt* Ptr { get => (TAt*) Unsafe.AsPointer(ref Ref); set => Ref = ref Unsafe.AsRef(value); } public RefPtr Offs(int offs) where T : unmanaged => new() { Ptr = (T*) ((nint) Ptr + offs) }; }