-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Implement slice::Vector for Option<T> and CVec<T> #16136
Conversation
I'm not convinced it really makes sense to think of |
I think, in truth, that the If I can take it further ... currently it feels like there is an inconsistency in
In practice, this means I can write a generic function In contrast, I can also write a function So it feels like there should be four traits:
Sorry, all a bit long ... |
|
@kballard Sure ... I just think that it might still prove useful if Not very important! |
FWIW, the |
So what do you think about implementing |
@bluss AFAIK tuples don't guarantee that they are laid out in memory the same way an array would be, which would be necessary in order to turn them into slices. |
The compiler actually already does this for it's own internal use. |
…arter-with-fns, r=Veykril fix(completion): make the expected type a tad smarter with `Fn`s This commit changes how the expected type is calculated when working with Fn pointers, making the parenthesis stop vanishing when completing the function name. I've been bugged by the behavior of parenthesis completion for a long while now. R-a assumes that the `LetStmt` type is the same as the function type I've just written. Worse is that all parenthesis vanish, even from functions that have completely different signatures. It will now verify if the signature is the same. While working on this, I noticed that record fields behave the same, so I also made it prioritize the field type instead of the current expression when possible, but I'm unsure if this is OK, so input is appreciated. ImplTraits as return types will still behave weirdly because lowering is disallowed at the time it resolves the function types.   
The
std::slice::Vector
trait effectively provides an interface for saying an object can give a slice view in to itself. BothOption<T>
andCVec<T>
exposeas_slice
but do so by implementing them directly rather than implementing them via theVector
trait.This patch alters both
Option<T>
andCVec<T>
to instead expose it by implementingVector
.