diff options
| author | Léo Lanteri Thauvin <leseulartichaut@gmail.com> | 2021-08-25 15:48:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-25 15:48:47 +0200 |
| commit | ccefe27670365f86cafbfa5b0776644980e919f0 (patch) | |
| tree | 47411110f6a2ed3abbdf52d0437d0d2832a86384 /tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff | |
| parent | 958d788a0b0cac81a0150c277b84746798f97b7d (diff) | |
| parent | 9c44d80c83eb250594ecad05ea5340e0b51af525 (diff) | |
| download | rust-ccefe27670365f86cafbfa5b0776644980e919f0.tar.gz rust-ccefe27670365f86cafbfa5b0776644980e919f0.zip | |
Rollup merge of #87944 - oconnor663:as_array_of_cells, r=scottmcm
add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells
I'd like to propose adding `Cell::as_array_of_cells`, as a natural analog to `Cell::as_slice_of_cells`. I don't have a specific use case in mind, other than that supporting slices but not arrays feels like a gap. Do other folks agree with that intuition? Would this addition be substantial enough to need an RFC?
---
Previously, converting `&mut [T; N]` to `&[Cell<T>; N]` looks like this:
```rust
let array = &mut [1, 2, 3];
let cells: &[Cell<i32>; 3] = Cell::from_mut(&mut array[..])
.as_slice_of_cells()
.try_into()
.unwrap();
```
With this new helper method, it looks like this:
```rust
let array = &mut [1, 2, 3];
let cells = Cell::from_mut(array).as_array_of_cells();
```
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff')
0 files changed, 0 insertions, 0 deletions
