I want to use a std::io::Cursor on a Vec<u8> sitting behind a Mutex to gain the Read/Write traits on that Vec. Yet since Read/Write/... are only implemented on Cursor<Vec<u8>> and not on Cursor<T: DerefMut<Target=Vec<u8>>> I do not see any way for me to use it.
I could just copy paste the code the implements Cursor<<Vec<u8>> and just reimplement it, but that seems less than ideal. Shouldn't Cursor be implemented on DerefMut? Or at least on &mut Vec<u8>>?
Note: Read/Write is implemented on Cursor<&'a mut [u8]> but that, obviously, doesn't allow the Write impl to actually change the size of the slice making it less than ideal.
I know this is an old question - but I almost made a new one because I ran into a similar issue. In my case, I wanted a Cursor<Arc<Vec<u8>>> that implements Read - but Cursor wasn't "reaching through" the Arc for the AsRef<[u8]> impl it needed on the vector.
The solution I found (which I found here) was to define a newtype that wraps Arc<Vec<u8>> and implement AsRef directly on that.
Not sure if that would work for the above case, but hopefully it helps someone else. (Particularly if they're trying to play sounds in rodio without cloning the audio.)