I still think I want to keep the default register api as-is, but I think a side effect (in rearch-effects) like the following would be a nice touch:
let register = register(effects::multi::<16>()); // 16 is const generic for size of backing array
let (count, set_count) = register(effects::state::<Cloned<_>>(0));
let mut num_builds = register(effects::value::<MutRef<_>>(0));
*num_builds += 1;
Note that in the above example, the backing array size could be 2. 16 is just chosen as a sane default.
This should be possible with 100% safe rust via split_first_mut:
curr_slice = &mut backing_array;
register:
let (curr_element, rest_slice) = self.curr_slice.split_first_mut().unwrap_or(|| panic!(“you need to increase length passed into multi!”));
*self.curr_slice = rest_slice;
return curr_element.some_cast_and_transform();
I still think I want to keep the default
registerapi as-is, but I think a side effect (inrearch-effects) like the following would be a nice touch:Note that in the above example, the backing array size could be 2. 16 is just chosen as a sane default.
This should be possible with 100% safe rust via
split_first_mut: