-
Notifications
You must be signed in to change notification settings - Fork 9
Remove bounds on as_flattened(_mut)
; make const fn
#144
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
Conversation
Also adds tests. Previously these used the core `[T]::as_flattened(_mut)` to avoid additional unsafe code, however instead this approach opts to use a similar strategy to how the upstream `as_flattened(_mut)` is implemented to avoid having to have a bound on the inner `ArrayType`.
Note: AFAICT this is non-breaking |
Wouldn't it be better to also do it for |
@newpavlov these methods are straightforward enough. The others aren’t, because the compiler lacks type information about the inner type, which is why it needs the hint. If you’d like to take a crack at it, go for it |
The cast methods are also straightforward and their implementation is nothing more than IIUC the UPD: Ah, don't mind. We can not do it since |
Yeah, due to the array sizes you need some kind of linkage that connects the two types, which is what the bound provides |
Also makes `as_flattened(_mut)` into `const fn`. This uses the same approach as `slice_as_flattened(_mut)` (#144), but constructs a slice of size `U::USIZE`.
Also adds tests.
Previously these used the core
[T]::as_flattened(_mut)
to avoid additional unsafe code, however instead this approach opts to use a similar strategy to how the upstreamas_flattened(_mut)
is implemented to avoid having to have a bound on the innerArrayType
.