File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,16 @@ public void TestFind() {
161161 Assert . Equal ( Array . Find ( arr , pred ) , imm . Find ( pred ) ) ;
162162 }
163163
164+ [ Fact ]
165+ public void TestSpan ( ) {
166+ var imm = Enumerable . Range ( - 1 , 100 ) . ToArray ( ) . ToImmArray ( ) ;
167+ var span = imm . Span ;
168+ Assert . Equal ( imm . Length , span . Length ) ;
169+ for ( int i = 0 ; i < imm . Length ; i ++ ) {
170+ Assert . Equal ( imm [ i ] , span [ i ] ) ;
171+ }
172+ }
173+
164174 public record Employee ( int Id , string Name , decimal Salary ) ;
165175}
166176
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ public ImmArray(IEnumerable<T> data) {
5555 }
5656 }
5757
58+ public ReadOnlySpan < T > Span => this . data ;
59+
5860 /// <inheritdoc />
5961 public T this [ int index ] => this . data [ index ] ;
6062
You can’t perform that action at this time.
0 commit comments