]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #78818 - scottmcm:as_rchunks, r=KodrAus
authorbors <bors@rust-lang.org>
Sun, 17 Jan 2021 05:43:55 +0000 (05:43 +0000)
committerbors <bors@rust-lang.org>
Sun, 17 Jan 2021 05:43:55 +0000 (05:43 +0000)
Add `as_rchunks` (and friends) to slices

`@est31` mentioned (https://github.com/rust-lang/rust/issues/76354#issuecomment-717027175) that, for completeness, there needed to be an `as_chunks`-like method that chunks from the end (with the remainder at the beginning) like `rchunks` does.

So here's a PR for `as_rchunks: &[T] -> (&[T], &[[T; N]])` and `as_rchunks_mut: &mut [T] -> (&mut [T], &mut [[T; N]])`.

But as I was doing this and copy-pasting `from_raw_parts` calls, I thought that I should extract that into an unsafe method.  It started out a private helper, but it seemed like `as_chunks_unchecked` could be reasonable as a "real" method, so I added docs and made it public.  Let me know if you think it doesn't pull its weight.


Trivial merge