-
Notifications
You must be signed in to change notification settings - Fork 526
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
feat: provide a Span<T>
to Array<T>
method
#5631
Comments
Do note that:
Should provide what you requested. |
Also - do note - that since (at least currently) a span is not the owner of its elements - In general - why do you actually need the |
I have to disagree about Having |
You consume the Span, not its elements. What will happen it something along those lines:
But I note that those implementation would only exist where |
You do not consume the span, as you cannot consume a copyable object (as any access to it would not consume the object) |
I'm not sure if we just disagree on words here or if there is something else, so I will try to be very explicit. Span impl Drop: A method that takes a span by value (not reference or snapshot) and doesn't return it, consumes the span by quietly calling drop on it after it's execution. Here is the signature of the
Here would be its implementation for span-to-array
The span passed as an argument will be dropped at the end of the function execution, therefore "consumed". But I understand that because |
I accept the |
From the caller's pov, because of Rust doc states: "A value-to-value conversion that consumes the input value.". |
Feature Request
Span<T>
is a wrapper around@Array<T>
.It should be possible to get the value out of this wrapper, either as
@Array<T>
orArray<T>
. Or both.Right now the only way to build back an
Array
from aSpan
is to iterate over it throughpop_front
. It is not a good DevX.Describe Preferred Solution
A counterpart to the
Array::span()
method.Span::consume -> Array
andSpan::snapshot -> @Array
maybe.Or implementations of the
Into
trait.Describe Alternatives
Implementations of the
Into
trait.Related Code
If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)
No, it's an important design decision, it should most likely be done by the project maintainers.
The text was updated successfully, but these errors were encountered: