This support was added to the commit, which also added tests . We can look at these tests to see how it should be used:
use std::cell::RefCell; #[test] fn refcell_unsized() { let cell: &RefCell<[i32]> = &RefCell::new([1, 2, 3]); { let b = &mut *cell.borrow_mut(); b[0] = 4; b[2] = 5; } let comp: &mut [i32] = &mut [4, 2, 5]; assert_eq!(&*cell.borrow(), comp); }
You always need to have a constructor with a Sized binding, since the compiler needs to know the amount of space to put on the stack. After that, you can force the type of dynamic size.
source share