Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Xledger.Collections.Test/TestImmArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ public void TestFind() {
Assert.Equal(Array.Find(arr, pred), imm.Find(pred));
}

[Fact]
public void TestSpan() {
var imm = Enumerable.Range(-1, 100).ToArray().ToImmArray();
var span = imm.Span;
Assert.Equal(imm.Length, span.Length);
for (int i = 0; i < imm.Length; i++) {
Assert.Equal(imm[i], span[i]);
}
}

public record Employee(int Id, string Name, decimal Salary);
}

2 changes: 2 additions & 0 deletions Xledger.Collections/ImmArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public ImmArray(IEnumerable<T> data) {
}
}

public ReadOnlySpan<T> Span => this.data;

/// <inheritdoc />
public T this[int index] => this.data[index];

Expand Down