2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-05-07 07:24:45 +00:00
|
|
|
|
2021-08-11 18:38:20 +00:00
|
|
|
#![feature(as_array_of_cells)]
|
|
|
|
|
2018-05-07 07:24:45 +00:00
|
|
|
use std::cell::Cell;
|
|
|
|
|
|
|
|
fn main() {
|
2018-05-28 06:35:12 +00:00
|
|
|
let slice: &mut [i32] = &mut [1, 2, 3];
|
2018-05-07 07:24:45 +00:00
|
|
|
let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
|
2018-07-23 11:20:50 +00:00
|
|
|
let slice_cell: &[Cell<i32>] = cell_slice.as_slice_of_cells();
|
2018-05-28 06:35:12 +00:00
|
|
|
|
2018-07-23 11:20:50 +00:00
|
|
|
assert_eq!(slice_cell.len(), 3);
|
2021-08-11 18:38:20 +00:00
|
|
|
|
|
|
|
let mut array: [i32; 3] = [1, 2, 3];
|
|
|
|
let cell_array: &Cell<[i32; 3]> = Cell::from_mut(&mut array);
|
|
|
|
let array_cell: &[Cell<i32>; 3] = cell_array.as_array_of_cells();
|
|
|
|
|
|
|
|
array_cell[0].set(99);
|
|
|
|
assert_eq!(array, [99, 2, 3]);
|
2018-05-07 07:24:45 +00:00
|
|
|
}
|