Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
CollectionsMarshal.AsSpan allow null refs (#26903)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored and tannergooding committed Sep 26, 2019
1 parent 0df1ede commit d0ad047
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 d0ad047

Please sign in to comment.