{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/149519296","pull_request_review_id":74926520,"id":149519296,"diff_hunk":"@@ -262,6 +262,73 @@ impl File {\n         OpenOptions::new().write(true).create(true).truncate(true).open(path.as_ref())\n     }\n \n+    /// Read the entire contents of a file into a bytes vector.\n+    ///\n+    /// This is a convenience function for using [`File::open`] and [`read_to_end`]\n+    /// with fewer imports and without an intermediate variable.\n+    ///\n+    /// [`File::open`]: struct.File.html#method.open\n+    /// [`read_to_end`]: ../io/trait.Read.html#method.read_to_end\n+    ///\n+    /// # Errors\n+    ///\n+    /// This function will return an error if `path` does not already exist.\n+    /// Other errors may also be returned according to [`OpenOptions::open`].\n+    ///\n+    /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open\n+    ///\n+    /// It will also return an error if it encounters while reading an error\n+    /// of a kind other than [`ErrorKind::Interrupted`].\n+    ///\n+    /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted\n+    ///\n+    /// # Examples\n+    ///\n+    /// ```no_run\n+    /// #![feature(file_read_write_contents)]\n+    ///\n+    /// use std::fs::File;\n+    ///\n+    /// # fn foo() -> Result<(), Box<std::error::Error + 'static>> {\n+    /// let foo = String::from_utf8(File::read_contents(\"foo.txt\")?)?;\n+    /// # Ok(())\n+    /// # }\n+    /// ```\n+    #[unstable(feature = \"file_read_write_contents\", issue = /* FIXME */ \"0\")]\n+    pub fn read_contents<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {\n+        let mut bytes = Vec::new();","path":"src/libstd/fs.rs","position":null,"original_position":38,"commit_id":"a379e697ab8ed7f3e73c79e303870ac208670bd7","original_commit_id":"fd518ac4b0fe30b13d2fdf0f1b4b9fa129d75dff","user":{"login":"mbrubeck","id":5920,"avatar_url":"https://avatars1.githubusercontent.com/u/5920?v=4","gravatar_id":"","url":"https://api.github.com/users/mbrubeck","html_url":"https://github.com/mbrubeck","followers_url":"https://api.github.com/users/mbrubeck/followers","following_url":"https://api.github.com/users/mbrubeck/following{/other_user}","gists_url":"https://api.github.com/users/mbrubeck/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrubeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrubeck/subscriptions","organizations_url":"https://api.github.com/users/mbrubeck/orgs","repos_url":"https://api.github.com/users/mbrubeck/repos","events_url":"https://api.github.com/users/mbrubeck/events{/privacy}","received_events_url":"https://api.github.com/users/mbrubeck/received_events","type":"User","site_admin":false},"body":"Specialization of `read_to_end` is a good idea. Filed #45851.\r\n\r\nNote that callers of `read_to_end` can already avoid quadratic behavior by passing in a pre-allocated buffer.  That workaround isn't available with the functions in this PR.","created_at":"2017-11-07T22:09:51Z","updated_at":"2017-11-07T22:09:51Z","html_url":"https://github.com/rust-lang/rust/pull/45837#discussion_r149519296","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/45837","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/149519296"},"html":{"href":"https://github.com/rust-lang/rust/pull/45837#discussion_r149519296"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/45837"}},"in_reply_to_id":149436611},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/45837","id":151166651,"html_url":"https://github.com/rust-lang/rust/pull/45837","diff_url":"https://github.com/rust-lang/rust/pull/45837.diff","patch_url":"https://github.com/rust-lang/rust/pull/45837.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/45837","number":45837,"state":"open","locked":false,"title":"Add read, read_utf8, and write functions to std::fs","user":{"login":"SimonSapin","id":291359,"avatar_url":"https://avatars0.githubusercontent.com/u/291359?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonSapin","html_url":"https://github.com/SimonSapin","followers_url":"https://api.github.com/users/SimonSapin/followers","following_url":"https://api.github.com/users/SimonSapin/following{/other_user}","gists_url":"https://api.github.com/users/SimonSapin/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSapin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSapin/subscriptions","organizations_url":"https://api.github.com/users/SimonSapin/orgs","repos_url":"https://api.github.com/users/SimonSapin/repos","events_url":"https://api.github.com/users/SimonSapin/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSapin/received_events","type":"User","site_admin":false},"body":"New APIs in `std::fs`:\r\n\r\n```rust\r\npub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { … }\r\npub fn read_utf8<P: AsRef<Path>>(path: P) -> io::Result<String> { … }\r\npub fn write<P: AsRef<Path>>(path: P, contents: &[u8]) -> io::Result<()> { … }\r\n```\r\n\r\n(`read_utf8` is based on `read_to_string` and so returns an error on non-UTF-8 content.)\r\n\r\nBefore:\r\n\r\n```rust\r\nuse std::fs::File;\r\nuse std::io::Read;\r\n\r\nlet mut bytes = Vec::new();\r\nFile::open(filename)?.read_to_end(&mut bytes)?;\r\ndo_something_with(bytes)\r\n```\r\n\r\nAfter:\r\n\r\n```rust\r\nuse std::fs;\r\n\r\ndo_something_with(fs::read(filename)?)\r\n```","created_at":"2017-11-07T16:43:24Z","updated_at":"2017-11-07T22:09:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be55ed7cbc7ff29a0ec59df65098fa7d3e67a00c","assignee":{"login":"dtolnay","id":1940490,"avatar_url":"https://avatars2.githubusercontent.com/u/1940490?v=4","gravatar_id":"","url":"https://api.github.com/users/dtolnay","html_url":"https://github.com/dtolnay","followers_url":"https://api.github.com/users/dtolnay/followers","following_url":"https://api.github.com/users/dtolnay/following{/other_user}","gists_url":"https://api.github.com/users/dtolnay/gists{/gist_id}","starred_url":"https://api.github.com/users/dtolnay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtolnay/subscriptions","organizations_url":"https://api.github.com/users/dtolnay/orgs","repos_url":"https://api.github.com/users/dtolnay/repos","events_url":"https://api.github.com/users/dtolnay/events{/privacy}","received_events_url":"https://api.github.com/users/dtolnay/received_events","type":"User","site_admin":false},"assignees":[{"login":"dtolnay","id":1940490,"avatar_url":"https://avatars2.githubusercontent.com/u/1940490?v=4","gravatar_id":"","url":"https://api.github.com/users/dtolnay","html_url":"https://github.com/dtolnay","followers_url":"https://api.github.com/users/dtolnay/followers","following_url":"https://api.github.com/users/dtolnay/following{/other_user}","gists_url":"https://api.github.com/users/dtolnay/gists{/gist_id}","starred_url":"https://api.github.com/users/dtolnay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtolnay/subscriptions","organizations_url":"https://api.github.com/users/dtolnay/orgs","repos_url":"https://api.github.com/users/dtolnay/repos","events_url":"https://api.github.com/users/dtolnay/events{/privacy}","received_events_url":"https://api.github.com/users/dtolnay/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/45837/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/45837/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/45837/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/a379e697ab8ed7f3e73c79e303870ac208670bd7","head":{"label":"SimonSapin:file_read_write","ref":"file_read_write","sha":"a379e697ab8ed7f3e73c79e303870ac208670bd7","user":{"login":"SimonSapin","id":291359,"avatar_url":"https://avatars0.githubusercontent.com/u/291359?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonSapin","html_url":"https://github.com/SimonSapin","followers_url":"https://api.github.com/users/SimonSapin/followers","following_url":"https://api.github.com/users/SimonSapin/following{/other_user}","gists_url":"https://api.github.com/users/SimonSapin/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSapin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSapin/subscriptions","organizations_url":"https://api.github.com/users/SimonSapin/orgs","repos_url":"https://api.github.com/users/SimonSapin/repos","events_url":"https://api.github.com/users/SimonSapin/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSapin/received_events","type":"User","site_admin":false},"repo":{"id":7715452,"name":"rust","full_name":"SimonSapin/rust","owner":{"login":"SimonSapin","id":291359,"avatar_url":"https://avatars0.githubusercontent.com/u/291359?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonSapin","html_url":"https://github.com/SimonSapin","followers_url":"https://api.github.com/users/SimonSapin/followers","following_url":"https://api.github.com/users/SimonSapin/following{/other_user}","gists_url":"https://api.github.com/users/SimonSapin/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSapin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSapin/subscriptions","organizations_url":"https://api.github.com/users/SimonSapin/orgs","repos_url":"https://api.github.com/users/SimonSapin/repos","events_url":"https://api.github.com/users/SimonSapin/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSapin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SimonSapin/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/SimonSapin/rust","forks_url":"https://api.github.com/repos/SimonSapin/rust/forks","keys_url":"https://api.github.com/repos/SimonSapin/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SimonSapin/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SimonSapin/rust/teams","hooks_url":"https://api.github.com/repos/SimonSapin/rust/hooks","issue_events_url":"https://api.github.com/repos/SimonSapin/rust/issues/events{/number}","events_url":"https://api.github.com/repos/SimonSapin/rust/events","assignees_url":"https://api.github.com/repos/SimonSapin/rust/assignees{/user}","branches_url":"https://api.github.com/repos/SimonSapin/rust/branches{/branch}","tags_url":"https://api.github.com/repos/SimonSapin/rust/tags","blobs_url":"https://api.github.com/repos/SimonSapin/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SimonSapin/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SimonSapin/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/SimonSapin/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SimonSapin/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/SimonSapin/rust/languages","stargazers_url":"https://api.github.com/repos/SimonSapin/rust/stargazers","contributors_url":"https://api.github.com/repos/SimonSapin/rust/contributors","subscribers_url":"https://api.github.com/repos/SimonSapin/rust/subscribers","subscription_url":"https://api.github.com/repos/SimonSapin/rust/subscription","commits_url":"https://api.github.com/repos/SimonSapin/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/SimonSapin/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/SimonSapin/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/SimonSapin/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/SimonSapin/rust/contents/{+path}","compare_url":"https://api.github.com/repos/SimonSapin/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SimonSapin/rust/merges","archive_url":"https://api.github.com/repos/SimonSapin/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SimonSapin/rust/downloads","issues_url":"https://api.github.com/repos/SimonSapin/rust/issues{/number}","pulls_url":"https://api.github.com/repos/SimonSapin/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/SimonSapin/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/SimonSapin/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SimonSapin/rust/labels{/name}","releases_url":"https://api.github.com/repos/SimonSapin/rust/releases{/id}","deployments_url":"https://api.github.com/repos/SimonSapin/rust/deployments","created_at":"2013-01-20T11:03:20Z","updated_at":"2014-08-09T22:01:15Z","pushed_at":"2017-11-07T17:42:55Z","git_url":"git://github.com/SimonSapin/rust.git","ssh_url":"git@github.com:SimonSapin/rust.git","clone_url":"https://github.com/SimonSapin/rust.git","svn_url":"https://github.com/SimonSapin/rust","homepage":"http://www.rust-lang.org","size":328920,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"3e7f501991df2f7fc87f6c340945112c128735d2","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2017-11-07T21:13:11Z","pushed_at":"2017-11-07T21:46:12Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"https://www.rust-lang.org","size":331456,"stargazers_count":24409,"watchers_count":24409,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4471,"mirror_url":null,"archived":false,"open_issues_count":3081,"forks":4471,"open_issues":3081,"watchers":24409,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/45837"},"html":{"href":"https://github.com/rust-lang/rust/pull/45837"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/45837"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/45837/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/45837/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/45837/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/a379e697ab8ed7f3e73c79e303870ac208670bd7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mbrubeck"}}