-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: MemoryMarshal.CreateReadOnlySpan that takes in
param
#83191
Comments
Tagging subscribers to this area: @dotnet/area-system-memory Issue DetailsBackground and motivationCurrently API Proposalnamespace System.Runtime.InteropServices;
public static partial class MemoryMarshal
{
public static ReadOnlySpan<T> CreateReadOnlySpan<T>(scoped in T reference, int length);
} API Usage// Fancy the value
readonly int _value;
MemoryMarshal.CreateReadOnlySpan(in _value, 1); Alternative DesignsNo response RisksNo response
|
I think the plan is to change the existing API to take a |
Yup, what @Sergio0694 said. And even if we wanted to we couldn't add the proposed method; we can't overload based on ref vs in. |
CC. @jaredpar since he's championing the issue. Just an FYI that this is "another" case that would be switched from |
Closing this as inactionable at the moment. We can revisit if the language adds support for |
Background and motivation
Currently
CreateReadOnlySpan
takes aref
so if a readonly field is passed it needs to first go viaUnsafe.AsRef(in
which seems an unnecessary friction of converting the type to non readonly.API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: