Essentially, I wanted to know the exact difference between
* Vec<usize>
* Vec<&usize>
* Vec<&mut usize>
* Vec<&mut &usize>
Specifically the last one
Vec<usize> - a vector containing usize numbersVec<&usize> - a vector containing references to usize numbers that are stored somewhere elseVec<&mut usize> - same as Vec<&usize>, but the referenced usize numbers can be modifiedVec<&mut &usize> - a vector containing references that point to other references that point to usize. The referenced references can be modified, but the usize numbers can not.Additional remarks:
Vec<&usize> is pointless. A &usize can only be used to access the values read-only, and everything that it can do can be done more efficiently with a Vec<usize>. For primitive types like usize, passing by-value is usually faster than by-reference for non-mutable access.Vec<&mut &usize> is very exotic and probably won't ever be encountered in real code.Vec<&mut &mut usize>. A vector containing references that point to other references that point to usize. The referenced references can be modified, as can the usize numbers.Vec<usize> and Vec<&mut usize> are probably the only two that matter. Although even that might be a stretch; realistically you will encounter Vec<usize>, &mut Vec<usize> and &[usize]. Maybe in rare cases &mut [usize].
Vec.