]> git.lizzy.rs Git - rust.git/commit
add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells
authorJack O'Connor <oconnor663@gmail.com>
Wed, 11 Aug 2021 18:38:20 +0000 (14:38 -0400)
committerJack O'Connor <oconnor663@gmail.com>
Mon, 23 Aug 2021 05:00:34 +0000 (01:00 -0400)
commit9c44d80c83eb250594ecad05ea5340e0b51af525
tree7a133a4ec3ba30f84d6613854fe59b1f496f579c
parent558553272d5f80ca6484ed3de961fe4f1a9d411d
add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells

Previously, converting `&mut [T; N]` to `&[Cell<T>; N]` looks like this:

    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:

    let array = &mut [1, 2, 3];
    let cells: &[Cell<i32>; 3] = Cell::from_mut(array).as_array_of_cells();
library/core/src/cell.rs
src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs