The only problem I can see with this is that writing methods using this will be a pain since you can’t have arbitrary
Also, you could probably stand to give a clearer example; it took me a few passes to realise what the core use of this is. It kinda gets lost in inferred types and maps (wait, there are iterators involved here?) Maybe a simple headline example like:
// Create an array owned by a Box.
let arr = Box::new([1, 2, 3, 4]) as Box<[i32]>;
// Transfer into a BoxRef.
let arr: BoxRef<[i32]> = BoxRef::new(arr);
assert_eq!(&*arr, &[1, 2, 3, 4]);
// We can slice the array without losing ownership or changing type.
let arr: BoxRef<[i32]> = arr.map(|arr| &arr[1..3]);
assert_eq!(&*arr, &[2, 3]);
// Also works for Arc, Rc, String and Vec!