Announcing cell-project

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!

6 Likes

It looks really handy. :smiley: Thanks!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.