Skip to content

Commit

Permalink
CollectionsMarshal.AsSpan allow null refs (dotnet/coreclr#26903)
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
benaadams authored and marek-safar committed Sep 26, 2019
1 parent 23fac78 commit 65dc4c3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class CollectionsMarshal
/// Get a <see cref="Span{T}"/> view over a <see cref="List{T}"/>'s data.
/// Items should not be added or removed from the <see cref="List{T}"/> while the <see cref="Span{T}"/> is in use.
/// </summary>
public static Span<T> AsSpan<T>(List<T> list)
=> new Span<T>(list._items, 0, list._size);
public static Span<T> AsSpan<T>(List<T>? list)
=> list is null ? default : new Span<T>(list._items, 0, list._size);
}
}

0 comments on commit 65dc4c3

Please sign in to comment.