Skip to content

Provide Read and Write access through Arc<T> if &T: Read/Write #53835

Closed
@jonhoo

Description

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions