Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add File::open_with() function to open files with options (e.g. read/write) #55762

Closed
Timmmm opened this issue Nov 7, 2018 · 2 comments
Closed
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Timmmm
Copy link
Contributor

Timmmm commented Nov 7, 2018

The current way to open a file is this:

File::open("foo.txt")

But if you want to open a file in with any options you do this:

use std::fs::OpenOptions;

let mut file = OpenOptions::new()
    .read(true)
    .write(true)
    .open("foo.txt");

It's weird that the options object does the actual opening. I propose that we deprecate OpenOptions::open() and add File::open_with(path: &str, options: &OpenOptions).

let mut file = File::open_with("foo.txt", OpenOptions::new().read().write());
@estebank estebank added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Nov 7, 2018
@steveklabnik
Copy link
Member

I'm not on the libs team, but this feels RFC-worthy to me.

@jonas-schievink jonas-schievink added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Oct 15, 2019
@Mark-Simulacrum
Copy link
Member

Closing in favor of #65439.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants