Skip to content

Commit

Permalink
Merge pull request #5 from rameel/fix-arrayview
Browse files Browse the repository at this point in the history
Fix an issue in `ArrayView<T>` incorrectly returned a mutable reference
  • Loading branch information
rameel authored Jul 10, 2024
2 parents 3cad21e + 39b5a77 commit 986fbae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Ramstack.Structures/Collections/ArrayView`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Ramstack.Collections;
public bool IsDefault => _array is null;

/// <inheritdoc cref="IReadOnlyList{T}.this"/>
public ref T this[int index]
public ref readonly T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
Expand Down Expand Up @@ -202,7 +202,7 @@ public ReadOnlyMemory<T> AsMemory() =>
/// A reference to the element of the <see cref="ArrayView{T}"/> at index zero.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref T GetPinnableReference()
public ref readonly T GetPinnableReference()
{
// To match the behavior of ReadOnlySpan<T>

Expand Down

0 comments on commit 986fbae

Please sign in to comment.