]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum
authorDylan DPC <dylan.dpc@gmail.com>
Thu, 3 Sep 2020 00:22:00 +0000 (02:22 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Sep 2020 00:22:00 +0000 (02:22 +0200)
commit10aa3d3f89195f6cab93700f2514744c814a4881
treeab6ffe562b4e9b637b5f7abf6ef7d1b47440fa93
parent536b0c0c9051f879e473f1040f94773ed070ebe9
parentd7afe2a223ab0a118bcdae39e8e2affbccaa61ae
Rollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum

Add `[T; N]::as_[mut_]slice`

Part of me trying to populate arrays with a couple of basic useful methods, like slices already have. The ability to add methods to arrays were added in #75212.  Tracking issue: #76118

This adds:

```rust
impl<T, const N: usize> [T; N] {
    pub fn as_slice(&self) -> &[T];
    pub fn as_mut_slice(&mut self) -> &mut [T];
}
```

These methods are like the ones on `std::array::FixedSizeArray` and in the crate `arraytools`.