diff --git a/src/gaemstone.ECS/Iterator.cs b/src/gaemstone.ECS/Iterator.cs index b35d818..939132a 100644 --- a/src/gaemstone.ECS/Iterator.cs +++ b/src/gaemstone.ECS/Iterator.cs @@ -144,7 +144,8 @@ public unsafe class Iterator public static SpanToRef Empty => default; private readonly Span _span; public int Length => _span.Length; - public T? this[int index] => (T?)_span[index].Target; + public T this[int index] => (T)_span[index].Target!; + public T? GetOrNull(int index) => ((index >= 0) && (index < Length)) ? this[index] : null; internal SpanToRef(Span span) => _span = span; } } diff --git a/src/gaemstone.Utility/SpanExtensions.cs b/src/gaemstone.Utility/SpanExtensions.cs index 3407363..3643a87 100644 --- a/src/gaemstone.Utility/SpanExtensions.cs +++ b/src/gaemstone.Utility/SpanExtensions.cs @@ -7,7 +7,7 @@ public static class SpanExtensions public static T? GetOrNull(this Span span, int index) where T : struct => GetOrNull((ReadOnlySpan)span, index); public static T? GetOrNull(this ReadOnlySpan span, int index) - where T : struct => (index >= 0 && index < span.Length) ? span[index] : null; + where T : struct => ((index >= 0) && (index < span.Length)) ? span[index] : null; public static ReadOnlySpanSplitEnumerator Split(this ReadOnlySpan span, T splitOn)