{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/22588","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/22588/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/22588/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/22588/events","html_url":"https://github.com/rust-lang/rust/issues/22588","id":58384501,"number":22588,"title":"BufRead::read_line is not as described in the io RFC","user":{"login":"mahkoh","id":1882250,"avatar_url":"https://avatars.githubusercontent.com/u/1882250?v=3","gravatar_id":"","url":"https://api.github.com/users/mahkoh","html_url":"https://github.com/mahkoh","followers_url":"https://api.github.com/users/mahkoh/followers","following_url":"https://api.github.com/users/mahkoh/following{/other_user}","gists_url":"https://api.github.com/users/mahkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/mahkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mahkoh/subscriptions","organizations_url":"https://api.github.com/users/mahkoh/orgs","repos_url":"https://api.github.com/users/mahkoh/repos","events_url":"https://api.github.com/users/mahkoh/events{/privacy}","received_events_url":"https://api.github.com/users/mahkoh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-io","name":"A-io","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-nominated","name":"I-nominated","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-02-20T17:30:53Z","updated_at":"2015-02-24T08:47:33Z","closed_at":null,"body":"```rust\r\n#![feature(io)]\r\n\r\nuse std::io::{BufRead};\r\n\r\nfn main() {\r\n    let buf = &[][];\r\n\r\n    let mut reader = std::old_io::BufReader::new(buf);\r\n    println!(\"{:?}\", reader.read_line());\r\n\r\n    let mut reader = std::io::BufReader::new(buf);\r\n    let mut dummy = String::new();\r\n    println!(\"{:?}\", reader.read_line(&mut dummy));\r\n}\r\n```\r\n```\r\nErr(IoError { kind: EndOfFile, desc: \"end of file\", detail: None })\r\nOk(())\r\n```\r\n>The read_until and read_line methods are changed to take explicit, mutable buffers, for similar reasons to read_to_end. (Note that buffer reuse is particularly common for read_line). These functions include the delimiters in the strings they produce, both for easy cross-platform compatibility (in the case of read_line) and for ease in copying data without loss (in particular, distinguishing whether the last line included a final delimiter).\r\n\r\nIn particular: No changes to the error semantics were mentioned in the RFC."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/75718999","html_url":"https://github.com/rust-lang/rust/issues/22588#issuecomment-75718999","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/22588","id":75718999,"user":{"login":"mahkoh","id":1882250,"avatar_url":"https://avatars.githubusercontent.com/u/1882250?v=3","gravatar_id":"","url":"https://api.github.com/users/mahkoh","html_url":"https://github.com/mahkoh","followers_url":"https://api.github.com/users/mahkoh/followers","following_url":"https://api.github.com/users/mahkoh/following{/other_user}","gists_url":"https://api.github.com/users/mahkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/mahkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mahkoh/subscriptions","organizations_url":"https://api.github.com/users/mahkoh/orgs","repos_url":"https://api.github.com/users/mahkoh/repos","events_url":"https://api.github.com/users/mahkoh/events{/privacy}","received_events_url":"https://api.github.com/users/mahkoh/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T08:47:33Z","updated_at":"2015-02-24T08:47:33Z","body":">It is not possible for the RFC to spell out 100% each minute implementation detail of all proposed functions and RFCs are intentionally left with wiggle room for the implementation.\r\n\r\nChanging the interface of read_line from\r\n```rust\r\nwhile let Ok(s) = buf.read_line() {\r\n    // code\r\n}\r\n```\r\nto\r\n```rust\r\nlet mut s = String::new();\r\nwhile buf.read_line(&mut s).is_ok() {\r\n    if s.len() == 0 {\r\n        break;\r\n    }\r\n    // code\r\n    s.truncate(0);\r\n}\r\n```\r\nIs not a minor change\r\n\r\n>It would be far more useful for you to make a case for this to return Err instead of sprinkling curt comments.\r\n\r\nI already discussed read_line and lines with @aturon *during* the RFC process. This was not part of our discussion."}}