I am trying to implement multiple "slices" over a shared array of objects. My solution is to morally make a
struct MySlice<T>{ shared_data: Rc<[T]> , beg: usize, len: usize }
I want to be able to implement both
impl From<Vec<T>> for MySlice<T> { /* ?? */ }
- and
fn get_mut_slice(&mut MySlice<T>) -> &mut [T]
which returns the entire underlying slice.
With the above implementation I can get the former but not the latter. I tried modifying the type into
struct MySlice1<T>{ shared_data: Rc<RefCell<[T]>> , beg: usize, len: usize }
But I couldn't get it to work. Is there an idiomatic way to get both?