cell-project
provides safe field projections through a shared mutable reference - &Cell<T>
!
use cell_project::cell_project as cp;
struct MyStruct {
id: u64,
data: Data,
}
fn get_id_smut(my_struct: &Cell<MyStruct>) -> &Cell<u64> {
cp!(MyStruct, my_struct.id)
}
With one limitation, you can't project to !Sized
fields. This limitation is lifted on nightly using the nightly_cell_project
macro!