Provide Read and Write access through Arc<T> if &T: Read/Write #53835
Closed
Description
opened on Aug 30, 2018
Some types (net:TcpStream
and fs:File
in particular) implement io::Read
and io::Write
on &'a T
. If one of these types are wrapped in an Arc
(or Rc
), there is no real reason why one shouldn't be able to call Read
or Write
methods on it. For example, this code should compile:
let mut x = Arc::new(TcpStream::connect("127.0.0.1:80")?);
x.read(&mut [0; 32])?;
I think this can be implemented pretty straightforwardly by adding the following impls to Arc
and Rc
:
impl<'a, T> io::Read for Arc<T> where &'a T: io::Read { .. }
impl<'a, T> io::Write for Arc<T> where &'a T: io::Write { .. }
Are there good reasons for why impls like these shouldn't be added?
Activity