Skip to content

tokio::fs::write clones the data #7183

@oriongonza

Description

@oriongonza

I get that it's supposed to be a 1 <-> 1 with std::fs::write but it copies whatever you give it and it doesn't even tell you about it until you look at the source code.

A better interface might be something like AsRef<[u8]> + Send + 'static so that you can pass owned data like Vec<u8>, Arc<[u8]>, bytes::Bytes...

However this is a breaking change as &[u8] could no longer be sent.

So either a new API for this or comment clearly that this will clone the data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateM-fsModule: tokio/fs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions