{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/54311960","id":54311960,"diff_hunk":"@@ -4568,6 +4588,99 @@ impl<A: Step + One> Iterator for ops::RangeFrom<A> where\n     }\n }\n \n+#[unstable(feature = \"inclusive_range\", reason = \"recently added, follows RFC\", issue = \"28237\")]\n+impl<A: Step + One> Iterator for ops::RangeInclusive<A> where\n+    for<'a> &'a A: Add<&'a A, Output = A>\n+{\n+    type Item = A;\n+\n+    #[inline]\n+    fn next(&mut self) -> Option<A> {\n+        use ops::RangeInclusive::*;\n+\n+        // this function has a sort of odd structure due to borrowck issues\n+        // we may need to replace self, so borrows of self.start and self.end need to end early\n+\n+        let (finishing, n) = match *self {\n+            Empty { .. } => (None, None), // empty iterators yield no values\n+\n+            NonEmpty { ref mut start, ref mut end } => {\n+                let one = A::one();\n+                if start <= end {\n+                    let mut n = &*start + &one;\n+                    mem::swap(&mut n, start);\n+\n+                    // if the iterator is done iterating, it will change from NonEmpty to Empty\n+                    // to avoid unnecessary drops or clones, we'll reuse either start or end\n+                    // (they are equal now, so it doesn't matter which)\n+                    // to pull out end, we need to swap something back in -- use the previously\n+                    // created A::one() as a dummy value\n+\n+                    (if n == *end { Some(mem::replace(end, one)) } else { None },\n+                    // ^ are we done yet?\n+                    Some(n)) // < the value to output\n+                } else {\n+                    (Some(mem::replace(start, one)), None)\n+                }\n+            }\n+        };\n+\n+        // turn into an empty iterator if this is the last value\n+        if let Some(end) = finishing {\n+            *self = Empty { at: end };\n+        }\n+\n+        n\n+    }\n+\n+    #[inline]\n+    fn size_hint(&self) -> (usize, Option<usize>) {\n+        use ops::RangeInclusive::*;\n+\n+        match *self {\n+            Empty { .. } => (0, Some(0)),\n+\n+            NonEmpty { ref start, ref end } =>\n+                match Step::steps_between(start, end, &A::one()) {\n+                    Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),\n+                    None => (0, None),\n+                }\n+        }\n+    }\n+}\n+\n+#[unstable(feature = \"inclusive_range\", reason = \"recently added, follows RFC\", issue = \"28237\")]\n+impl<A: Step + One> DoubleEndedIterator for ops::RangeInclusive<A> where\n+    for<'a> &'a A: Add<&'a A, Output = A>,\n+    for<'a> &'a A: Sub<&'a A, Output = A>\n+{\n+    #[inline]\n+    fn next_back(&mut self) -> Option<A> {\n+        use ops::RangeInclusive::*;\n+\n+        // see Iterator::next for comments\n+\n+        let (finishing, n) = match *self {\n+            Empty { .. } => return None,\n+\n+            NonEmpty { ref mut start, ref mut end } => {\n+                let one = A::one();\n+                let mut n = &*end - &one;","path":"src/libcore/iter.rs","position":334,"original_position":334,"commit_id":"dd0bd92a71433d3c23738bfcc4f8070655e19d8e","original_commit_id":"dd0bd92a71433d3c23738bfcc4f8070655e19d8e","user":{"login":"durka","id":47007,"avatar_url":"https://avatars.githubusercontent.com/u/47007?v=3","gravatar_id":"","url":"https://api.github.com/users/durka","html_url":"https://github.com/durka","followers_url":"https://api.github.com/users/durka/followers","following_url":"https://api.github.com/users/durka/following{/other_user}","gists_url":"https://api.github.com/users/durka/gists{/gist_id}","starred_url":"https://api.github.com/users/durka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durka/subscriptions","organizations_url":"https://api.github.com/users/durka/orgs","repos_url":"https://api.github.com/users/durka/repos","events_url":"https://api.github.com/users/durka/events{/privacy}","received_events_url":"https://api.github.com/users/durka/received_events","type":"User","site_admin":false},"body":"Sure could. I'll add a guard for `start <= end`. ","created_at":"2016-02-26T22:34:51Z","updated_at":"2016-02-26T22:34:51Z","html_url":"https://github.com/rust-lang/rust/pull/30884#discussion_r54311960","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/30884","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/54311960"},"html":{"href":"https://github.com/rust-lang/rust/pull/30884#discussion_r54311960"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30884"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/30884","id":55968983,"html_url":"https://github.com/rust-lang/rust/pull/30884","diff_url":"https://github.com/rust-lang/rust/pull/30884.diff","patch_url":"https://github.com/rust-lang/rust/pull/30884.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/30884","number":30884,"state":"open","locked":false,"title":"implement RFC 1192 inclusive ranges","user":{"login":"durka","id":47007,"avatar_url":"https://avatars.githubusercontent.com/u/47007?v=3","gravatar_id":"","url":"https://api.github.com/users/durka","html_url":"https://github.com/durka","followers_url":"https://api.github.com/users/durka/followers","following_url":"https://api.github.com/users/durka/following{/other_user}","gists_url":"https://api.github.com/users/durka/gists{/gist_id}","starred_url":"https://api.github.com/users/durka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durka/subscriptions","organizations_url":"https://api.github.com/users/durka/orgs","repos_url":"https://api.github.com/users/durka/repos","events_url":"https://api.github.com/users/durka/events{/privacy}","received_events_url":"https://api.github.com/users/durka/received_events","type":"User","site_admin":false},"body":"This PR implements [RFC 1192](https://github.com/rust-lang/rfcs/blob/master/text/1192-inclusive-ranges.md), which is triple-dot syntax for inclusive range expressions. The new stuff is behind two feature gates (one for the syntax and one for the std::ops types). This replaces the deprecated functionality in std::iter. Along the way I simplified the desugaring for all ranges.\r\n\r\nThis is my first contribution to rust which changes more than one character outside of a test or comment, so please review carefully! Some of the individual commit messages have more of my notes. Also thanks for putting up with my dumb questions in #rust-internals.\r\n\r\n#### Notes\r\n\r\n- For implementing `std::ops::RangeInclusive`, I took @Stebalien's suggestion from https://github.com/rust-lang/rfcs/pull/1192#issuecomment-137864421. It seemed to me to make the implementation easier and increase type safety. If that stands, the RFC should be amended to avoid confusion.\r\n- I also kind of like @glaebhoerl's [idea](https://github.com/rust-lang/rfcs/pull/1254#issuecomment-147815299), which is unified inclusive/exclusive range syntax something like `x>..=y`. We can experiment with this while everything is behind a feature gate.\r\n- There are a couple of FIXMEs left (see the last commit). I didn't know what to do about `RangeArgument` and I haven't added `Index` impls yet. Those should be discussed/finished before merging.\r\n\r\ncc @Gankro since you [complained](https://www.reddit.com/r/rust/comments/3xkfro/what_happened_to_inclusive_ranges/cy5j0yq)\r\ncc #27777 #30877 rust-lang/rust#1192 rust-lang/rfcs#1254\r\nrelevant to #28237 (tracking issue)","created_at":"2016-01-13T22:56:05Z","updated_at":"2016-02-26T22:34:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c896cc7bd402bf0a6176ac2b87dbdc9ceeb63a0","assignee":{"login":"aturon","id":709807,"avatar_url":"https://avatars.githubusercontent.com/u/709807?v=3","gravatar_id":"","url":"https://api.github.com/users/aturon","html_url":"https://github.com/aturon","followers_url":"https://api.github.com/users/aturon/followers","following_url":"https://api.github.com/users/aturon/following{/other_user}","gists_url":"https://api.github.com/users/aturon/gists{/gist_id}","starred_url":"https://api.github.com/users/aturon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aturon/subscriptions","organizations_url":"https://api.github.com/users/aturon/orgs","repos_url":"https://api.github.com/users/aturon/repos","events_url":"https://api.github.com/users/aturon/events{/privacy}","received_events_url":"https://api.github.com/users/aturon/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/30884/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/30884/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/30884/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/dd0bd92a71433d3c23738bfcc4f8070655e19d8e","head":{"label":"durka:inclusive-ranges","ref":"inclusive-ranges","sha":"dd0bd92a71433d3c23738bfcc4f8070655e19d8e","user":{"login":"durka","id":47007,"avatar_url":"https://avatars.githubusercontent.com/u/47007?v=3","gravatar_id":"","url":"https://api.github.com/users/durka","html_url":"https://github.com/durka","followers_url":"https://api.github.com/users/durka/followers","following_url":"https://api.github.com/users/durka/following{/other_user}","gists_url":"https://api.github.com/users/durka/gists{/gist_id}","starred_url":"https://api.github.com/users/durka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durka/subscriptions","organizations_url":"https://api.github.com/users/durka/orgs","repos_url":"https://api.github.com/users/durka/repos","events_url":"https://api.github.com/users/durka/events{/privacy}","received_events_url":"https://api.github.com/users/durka/received_events","type":"User","site_admin":false},"repo":{"id":35621931,"name":"rust","full_name":"durka/rust","owner":{"login":"durka","id":47007,"avatar_url":"https://avatars.githubusercontent.com/u/47007?v=3","gravatar_id":"","url":"https://api.github.com/users/durka","html_url":"https://github.com/durka","followers_url":"https://api.github.com/users/durka/followers","following_url":"https://api.github.com/users/durka/following{/other_user}","gists_url":"https://api.github.com/users/durka/gists{/gist_id}","starred_url":"https://api.github.com/users/durka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durka/subscriptions","organizations_url":"https://api.github.com/users/durka/orgs","repos_url":"https://api.github.com/users/durka/repos","events_url":"https://api.github.com/users/durka/events{/privacy}","received_events_url":"https://api.github.com/users/durka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/durka/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/durka/rust","forks_url":"https://api.github.com/repos/durka/rust/forks","keys_url":"https://api.github.com/repos/durka/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/durka/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/durka/rust/teams","hooks_url":"https://api.github.com/repos/durka/rust/hooks","issue_events_url":"https://api.github.com/repos/durka/rust/issues/events{/number}","events_url":"https://api.github.com/repos/durka/rust/events","assignees_url":"https://api.github.com/repos/durka/rust/assignees{/user}","branches_url":"https://api.github.com/repos/durka/rust/branches{/branch}","tags_url":"https://api.github.com/repos/durka/rust/tags","blobs_url":"https://api.github.com/repos/durka/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/durka/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/durka/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/durka/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/durka/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/durka/rust/languages","stargazers_url":"https://api.github.com/repos/durka/rust/stargazers","contributors_url":"https://api.github.com/repos/durka/rust/contributors","subscribers_url":"https://api.github.com/repos/durka/rust/subscribers","subscription_url":"https://api.github.com/repos/durka/rust/subscription","commits_url":"https://api.github.com/repos/durka/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/durka/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/durka/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/durka/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/durka/rust/contents/{+path}","compare_url":"https://api.github.com/repos/durka/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/durka/rust/merges","archive_url":"https://api.github.com/repos/durka/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/durka/rust/downloads","issues_url":"https://api.github.com/repos/durka/rust/issues{/number}","pulls_url":"https://api.github.com/repos/durka/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/durka/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/durka/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/durka/rust/labels{/name}","releases_url":"https://api.github.com/repos/durka/rust/releases{/id}","deployments_url":"https://api.github.com/repos/durka/rust/deployments","created_at":"2015-05-14T16:17:36Z","updated_at":"2016-01-12T21:01:17Z","pushed_at":"2016-02-23T21:08:37Z","git_url":"git://github.com/durka/rust.git","ssh_url":"git@github.com:durka/rust.git","clone_url":"https://github.com/durka/rust.git","svn_url":"https://github.com/durka/rust","homepage":"http://www.rust-lang.org","size":281252,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"57c357d89183df173b0e42a0f745d9cfdb67fb1a","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","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://avatars.githubusercontent.com/u/5430905?v=3","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":"2016-02-26T19:20:44Z","pushed_at":"2016-02-26T22:22:00Z","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":"http://www.rust-lang.org","size":471679,"stargazers_count":15423,"watchers_count":15423,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2993,"mirror_url":null,"open_issues_count":2324,"forks":2993,"open_issues":2324,"watchers":15423,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30884"},"html":{"href":"https://github.com/rust-lang/rust/pull/30884"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/30884"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/30884/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30884/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/30884/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/dd0bd92a71433d3c23738bfcc4f8070655e19d8e"}}}}