-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking Issue for Stdin::lines
forwarder method
#87096
Comments
These methods have been around for a while, and they seem reasonable. I think it'd be appropriate to consider stabilizing them. @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
If #86845 ended up making |
#15023 is an accepted RFC to just make I think I would want to check in with the lang team and/or compiler team on an outlook for that before we start adding surface area like this only motivated by working around it. @rfcbot concern better temporary lifetimes |
We discussed this API briefly in the libs-api meeting. After another look, I am on board with these methods since the motivation isn't just about working around the way that temporary lifetimes are currently handled — it's beneficial to be able to iterate lines of stdin without needing to consider that locking needs to be involved. @rfcbot resolve better temporary lifetimes |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Two non-strong feelings:
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
@rfcbot concern split-is-too-niche Yeah I think there is some concern with Also, these APIs are very poorly documented at the moment. I kind of feel like APIs should have full documentation on them before we consider stabilization. For example, I think these APIs should mention the motivation for their existence, in that it permits more convenient line iteration when compared to having to deal with locking stdin explicitly. |
@BurntSushi I'm willing to remove the |
I'm not opposed to dropping |
Thanks; I'll work on a PR to delete the |
#93134 if someone who's already commented here is interested in reviewing it. maybe @joshtriplett ? |
For what its worth I've used split for processing input with a non-endline separator, but I agree that the implementation here is probably not the one we want for the sake of consistency. Perhaps the idea would be worth revisiting but behind another feature flag as to not stop the stabilization of the other method. |
delete `Stdin::split` forwarder Part of rust-lang#87096. Delete the `Stdin::split` forwarder because it's seen as too niche to expose at this level. `@rustbot` label T-libs-api A-io
@BurntSushi The removal of |
@rfcbot resolve split-is-too-niche |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Stdin::lines
, Stdin::split
forwarder methodsStdin::lines
, ~~Stdin::split
~~ forwarder method~~s~~
Stdin::lines
, ~~Stdin::split
~~ forwarder method~~s~~Stdin::lines
forwarder method
Looks like rfcbot is sleeping (: 🤖 📣 The final comment period, with a disposition to merge, as per the review above, is now complete. As the temporary human substitute for the temporarily unavailable automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
rfcbot commented earlier (#87096 (comment)), so I guess it got confused by the concern+resolve after the FCP had "completed". |
…rk-Simulacrum Stabilize Stdin::lines. Closes rust-lang#87096 Fcp completed here: rust-lang#87096 (comment)
…crum Stabilize Stdin::lines. Closes rust-lang/rust#87096 Fcp completed here: rust-lang/rust#87096 (comment)
The feature is now merged AFAIK: rust-lang/rust#87096
Feature gate:
#![feature(stdin_forwarders)]
This is a tracking issue for adding new methods
Stdin::lines
andthat will forward to the corresponding methods on theStdin::split
BufRead
implementation ofStdinLock
. This proposal is related to #86845, and further reduces the obstacles for beginners to write simple interactive terminal programs.Especially for beginners, reading a sequence of lines from the standard input stream can involve intimidating problems with locking and lifetimes. First, the user has to call the free function
stdin()
to get a handle on the stream; then, the user would have to call thelock()
method to gain access to thelines()
method. At this point, lifetime issues rapidly arise: the following code (playground)produces this error:
The need to create a
let
binding to the handle seems confusing and frustrating, especially if the program does not need to use the handle again. The explanation is that the lock (and the iterator produced bylines()
) behaves as if it borrows the original handle fromstdin()
, and the temporary value created for the call to thelock()
method is dropped at the end of the statement, invalidating the borrow. That explanation might be beyond the current level of understanding of a beginner who simply wants to write an interactive terminal program.Although #86845 makes it easier to obtain locked stdio handles, it would be even better if beginners didn't have to deal with the concept of locking at all at early stages of their learning.
There is precedent in the
Stdin::read_line
forwarder method that implicitly locksStdin
and calls theBufRead::read_line
method. However,read_line()
is somewhat difficult to use, because it requires that the user first allocate aString
, and it doesn't remove newlines. In contrast,lines()
provides an iterator over input lines that removes line endings, including both carriage return (CR) and line feed (LF) characters.This proposal also includes aThe remaining exclusive methods ofsplit()
forwarder method, because it is similar in nature and usability to thelines()
method.BufRead
are less useful to beginners, and require more experience to use.Public API
Steps / History
Stdin::lines
,Stdin::split
forwarder methods #86847split
forwarder deleteStdin::split
forwarder #93134Unresolved Questions
@rustbot label +A-io +D-newcomer-roadblock
The text was updated successfully, but these errors were encountered: