This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit b578433e37
2 changed files with 784842 additions and 0 deletions

View file

@ -0,0 +1,27 @@
namespace Brutal;
/// <summary>
/// Interface for a type that can be null
/// </summary>
public interface INullable
{
/// <summary>
/// Returns true if the instance is null
/// </summary>
public bool IsNull();
}
/// <summary>
/// Extensions for INullable
/// </summary>
public static class NullableExtensions
{
/// <summary>
/// Returns true if the instance is not null
/// </summary>
public static bool IsNotNull<T>(this T nullable)
where T : INullable
{
return !nullable.IsNull();
}
}

View file

@ -0,0 +1,22 @@
using Brutal.Pointers;
namespace Brutal;
public interface ISpanLike : INullable
{
public Ptr Ptr { get; }
public ElementCount Length { get; }
public ByteSize Stride { get; }
public bool IsEmpty { get; }
public Span<T> AsSpan<T>()
where T : unmanaged;
}
public interface ISpanLike<T> : ISpanLike
where T : unmanaged
{
public new Ptr<T> Ptr { get; }
public Span<T> AsSpan();
}