-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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::with_options #65429
Add File::with_options #65429
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @shepmaster (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
You do have to create one
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
spurious error? @shepmaster could you trigger the build process again? or even better: @Timmmm please squash and rebase your commits and then force push them :) |
That's docker hub problem: https://status.docker.com/pages/incident/533c6539221ae15e3f000031/5da5fc78c7b1c11cd8603721 |
This provides a more fluent API to create files with options, and also avoids the need to import OpenOptions.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@timmm are you able to fix that or do you need help? (hint: take a look at Lines 97 to 105 in f54911c
|
At last :-D Sorry for using the CI system as my build tool... Next time I will compile it myself! |
Ping from triage: @shepmaster Can you please review this PR? Thanks |
Pinging again from triage: @shepmaster Can you please review this PR? Thanks |
@bors r+ Seems like some libs folks were in favor of this on the associated RFC so we can probably move ahead here (it's an unstable feature anyway). |
📌 Commit c8150cb has been approved by |
@@ -397,6 +399,37 @@ impl File { | |||
OpenOptions::new().write(true).create(true).truncate(true).open(path.as_ref()) | |||
} | |||
|
|||
/// Returns a new OpenOptions object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add link for this
/// Returns a new OpenOptions object. | |
/// Returns a new [OpenOptions] object. |
/// open or create a file with specific options if `open()` or `create()` | ||
/// are not appropriate. | ||
/// | ||
/// It is equivalent to `OpenOptions::new()` but allows you to write more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// It is equivalent to `OpenOptions::new()` but allows you to write more | |
/// It is equivalent to [`OpenOptions::new()`] but allows you to write more |
/// you can write `File::with_options().read(true).open("foo.txt"). This | ||
/// also avoids the need to import `OpenOptions`. | ||
/// | ||
/// See the [`OpenOptions::new`] function for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// See the [`OpenOptions::new`] function for more details. |
/// This function returns a new OpenOptions object that you can use to | ||
/// open or create a file with specific options if `open()` or `create()` | ||
/// are not appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove theses lines.
Add File::with_options This provides a more fluent API to create files with options, and also avoids the need to import OpenOptions. This implements @aldanor's [suggestion](rust-lang/rfcs#2615 (comment)) which was popular.
☀️ Test successful - checks-azure |
This provides a more fluent API to create files with options, and also avoids the need to import OpenOptions.
This implements @aldanor's suggestion which was popular.