{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/1624","repository_url":"https://api.github.com/repos/rust-lang/rfcs","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1624/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1624/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1624/events","html_url":"https://github.com/rust-lang/rfcs/pull/1624","id":156023572,"number":1624,"title":"loop-break-value (issue #961)","user":{"login":"dhardy","id":134893,"avatar_url":"https://avatars.githubusercontent.com/u/134893?v=3","gravatar_id":"","url":"https://api.github.com/users/dhardy","html_url":"https://github.com/dhardy","followers_url":"https://api.github.com/users/dhardy/followers","following_url":"https://api.github.com/users/dhardy/following{/other_user}","gists_url":"https://api.github.com/users/dhardy/gists{/gist_id}","starred_url":"https://api.github.com/users/dhardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhardy/subscriptions","organizations_url":"https://api.github.com/users/dhardy/orgs","repos_url":"https://api.github.com/users/dhardy/repos","events_url":"https://api.github.com/users/dhardy/events{/privacy}","received_events_url":"https://api.github.com/users/dhardy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/final-comment-period","name":"final-comment-period","color":"207de5"},{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/T-lang","name":"T-lang","color":"bfd4f2"}],"state":"open","locked":false,"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},"assignees":[{"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,"comments":20,"created_at":"2016-05-20T18:28:22Z","updated_at":"2016-09-22T12:13:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1624","html_url":"https://github.com/rust-lang/rfcs/pull/1624","diff_url":"https://github.com/rust-lang/rfcs/pull/1624.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/1624.patch"},"body":"This is the culmination of recent discussion in issue #961, minus discussion about extensions to for/while/while let (for which there is no clear solution)."},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/248886272","html_url":"https://github.com/rust-lang/rfcs/pull/1624#issuecomment-248886272","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1624","id":248886272,"user":{"login":"dhardy","id":134893,"avatar_url":"https://avatars.githubusercontent.com/u/134893?v=3","gravatar_id":"","url":"https://api.github.com/users/dhardy","html_url":"https://github.com/dhardy","followers_url":"https://api.github.com/users/dhardy/followers","following_url":"https://api.github.com/users/dhardy/following{/other_user}","gists_url":"https://api.github.com/users/dhardy/gists{/gist_id}","starred_url":"https://api.github.com/users/dhardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhardy/subscriptions","organizations_url":"https://api.github.com/users/dhardy/orgs","repos_url":"https://api.github.com/users/dhardy/repos","events_url":"https://api.github.com/users/dhardy/events{/privacy}","received_events_url":"https://api.github.com/users/dhardy/received_events","type":"User","site_admin":false},"created_at":"2016-09-22T12:13:52Z","updated_at":"2016-09-22T12:13:52Z","body":"@Thiez you're right, those examples can be simplified. I wasn't very familiar with the `let x; loop { ... { x = y; break; } }` pattern when I wrote the RFC. Contrary to what @JelteF says, the pattern even appears to work with multiple break points (though each \"break\" requires two lines of code).\r\n\r\n```\r\nlet computation;\r\nloop {\r\n    if let Some(r) = self.do_something() {\r\n        computation = r;\r\n        break;\r\n    }\r\n}\r\nlet computation = computation.do_computation();\r\nself.use(computation);\r\n```\r\nThis example however won't always work with the current lifetime restrictions, since `r` may contain a reference to `self` (hence doing `r.do_computation()` early; this was one of the examples motivating this RFC)."}}
{"actor":{"display_login":"dhardy"}}