{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/130231322","pull_request_review_id":53086544,"id":130231322,"diff_hunk":"@@ -1960,6 +1960,65 @@ impl<T> Vec<T> {\n         }\n     }\n \n+    /// Creates an iterator which uses a closure to determine if an element should be removed.\n+    ///\n+    /// If the closure returns true, then the element is removed and yielded.\n+    /// If the closure returns false, it will try again, and call the closure\n+    /// on the next element, seeing if it passes the test.\n+    ///\n+    /// Using this method is equivalent to the following code:\n+    ///\n+    /// ```\n+    /// # let some_predicate = |x: &mut i32| { *x == 2 };\n+    /// # let mut vec = vec![1, 2, 3, 4, 5];\n+    /// let mut i = 0;\n+    /// while i != vec.len() {\n+    ///     if some_predicate(&mut vec[i]) {\n+    ///         let val = vec.remove(i);\n+    ///         // your code here\n+    ///     }\n+    ///     i += 1;","path":"src/liballoc/vec.rs","position":21,"original_position":21,"commit_id":"1af42261e142c20c1aed30732ad77bf3560318a1","original_commit_id":"1af42261e142c20c1aed30732ad77bf3560318a1","user":{"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},"body":"This would skip every item after a removed item.\r\n\r\n```rust\r\nlet some_predicate = |&x| x == 2;\r\nlet mut vec = vec![1, 2, 2, 3, 4, 5]; \r\n\r\nlet mut i = 0;\r\nwhile i != vec.len() {\r\n    if some_predicate(&mut vec[i]) {\r\n        let val = vec.remove(i);\r\n        println!(\"removed {}\", val);\r\n    }\r\n    i += 1;\r\n}\r\n\r\nprintln!(\"{:?}\", vec);\r\n```","created_at":"2017-07-30T00:55:03Z","updated_at":"2017-07-30T00:57:12Z","html_url":"https://github.com/rust-lang/rust/pull/43245#discussion_r130231322","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/43245","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/130231322"},"html":{"href":"https://github.com/rust-lang/rust/pull/43245#discussion_r130231322"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/43245"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/43245","id":130699584,"html_url":"https://github.com/rust-lang/rust/pull/43245","diff_url":"https://github.com/rust-lang/rust/pull/43245.diff","patch_url":"https://github.com/rust-lang/rust/pull/43245.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/43245","number":43245,"state":"open","locked":false,"title":"Add Vec::drain_filter","user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars1.githubusercontent.com/u/1136864?v=4","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"body":"This implements the API proposed in #43244.\r\n\r\nSo I spent like half a day figuring out how to implement this in some awesome super-optimized unsafe way, which had me very confident this was worth putting into the stdlib. \r\n\r\nThen I looked at the impl for `retain`, and was like \"oh dang\". I compared the two and they basically ended up being the same speed. And the `retain` impl probably translates to DoubleEndedIter a lot more cleanly if we ever want that.\r\n\r\nSo now I'm not totally confident this needs to go in the stdlib, but I've got two implementations and an amazingly robust test suite, so I figured I might as well toss it over the fence for discussion.","created_at":"2017-07-15T02:02:50Z","updated_at":"2017-07-30T00:57:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd75df041306b56709e68165ad3c6e6afb9a6e02","assignee":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"assignees":[{"login":"sfackler","id":1455697,"avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/43245/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/43245/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/43245/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/1af42261e142c20c1aed30732ad77bf3560318a1","head":{"label":"Gankro:drain-filter","ref":"drain-filter","sha":"1af42261e142c20c1aed30732ad77bf3560318a1","user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars1.githubusercontent.com/u/1136864?v=4","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"repo":{"id":21621250,"name":"rust","full_name":"Gankro/rust","owner":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars1.githubusercontent.com/u/1136864?v=4","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Gankro/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/Gankro/rust","forks_url":"https://api.github.com/repos/Gankro/rust/forks","keys_url":"https://api.github.com/repos/Gankro/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Gankro/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Gankro/rust/teams","hooks_url":"https://api.github.com/repos/Gankro/rust/hooks","issue_events_url":"https://api.github.com/repos/Gankro/rust/issues/events{/number}","events_url":"https://api.github.com/repos/Gankro/rust/events","assignees_url":"https://api.github.com/repos/Gankro/rust/assignees{/user}","branches_url":"https://api.github.com/repos/Gankro/rust/branches{/branch}","tags_url":"https://api.github.com/repos/Gankro/rust/tags","blobs_url":"https://api.github.com/repos/Gankro/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Gankro/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Gankro/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/Gankro/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Gankro/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/Gankro/rust/languages","stargazers_url":"https://api.github.com/repos/Gankro/rust/stargazers","contributors_url":"https://api.github.com/repos/Gankro/rust/contributors","subscribers_url":"https://api.github.com/repos/Gankro/rust/subscribers","subscription_url":"https://api.github.com/repos/Gankro/rust/subscription","commits_url":"https://api.github.com/repos/Gankro/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/Gankro/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/Gankro/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/Gankro/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/Gankro/rust/contents/{+path}","compare_url":"https://api.github.com/repos/Gankro/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Gankro/rust/merges","archive_url":"https://api.github.com/repos/Gankro/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Gankro/rust/downloads","issues_url":"https://api.github.com/repos/Gankro/rust/issues{/number}","pulls_url":"https://api.github.com/repos/Gankro/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/Gankro/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/Gankro/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Gankro/rust/labels{/name}","releases_url":"https://api.github.com/repos/Gankro/rust/releases{/id}","deployments_url":"https://api.github.com/repos/Gankro/rust/deployments","created_at":"2014-07-08T16:53:48Z","updated_at":"2017-07-14T23:14:45Z","pushed_at":"2017-07-19T14:46:36Z","git_url":"git://github.com/Gankro/rust.git","ssh_url":"git@github.com:Gankro/rust.git","clone_url":"https://github.com/Gankro/rust.git","svn_url":"https://github.com/Gankro/rust","homepage":"http://www.rust-lang.org","size":313920,"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,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"4e56bbeb19c48edf6a211448a6fb5b67b29eceec","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-07-29T22:30:40Z","pushed_at":"2017-07-30T00:48:53Z","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":318437,"stargazers_count":22811,"watchers_count":22811,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4193,"mirror_url":null,"open_issues_count":2726,"forks":4193,"open_issues":2726,"watchers":22811,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/43245"},"html":{"href":"https://github.com/rust-lang/rust/pull/43245"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/43245"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/43245/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/43245/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/43245/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/1af42261e142c20c1aed30732ad77bf3560318a1"}}}}
{"actor":{"display_login":"dtolnay"}}