{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/22983525","id":22983525,"diff_hunk":"@@ -0,0 +1,184 @@\n+- Start Date: (fill me in with today's date, YYYY-MM-DD)\n+- RFC PR #: (leave this empty)\n+- Rust Issue #: (leave this empty)\n+\n+# Summary\n+\n+The `Fn` traits should be modified to make the return type an associated type.\n+\n+# Motivation\n+\n+The strongest reason is because it would permit impls like the following\n+(example from @alexcrichton):\n+\n+```rust\n+impl<R,F> Foo for F : FnMut() -> R { ... }\n+```\n+\n+This impl is currently illegal because the parameter `R` is not\n+constrained. (This also has an impact on my attempts to add variance,\n+which would require a \"phantom data\" annotation for `R` for the same\n+reason; but that RFC is not quite ready yet.)\n+\n+Another related reason is that it often permits fewer type parameters.\n+Rather than having a distinct type parameter for the return type, the\n+associated type projection `F::Output` can be used. Consider the standard\n+library `Map` type:\n+\n+```rust\n+struct Map<A,B,I,F>\n+    where I : Iterator<Item=A>,\n+          F : FnMut(A) -> B,\n+{\n+    ...\n+}\n+\n+impl<A,B,I,F> Iterator for Map<A,B,I,F>\n+    where I : Iterator<Item=A>,\n+          F : FnMut(A) -> B,\n+{\n+    type Item = B;\n+    ...\n+}\n+```\n+\n+This type could be equivalently written:\n+\n+```rust\n+struct Map<I,F>\n+    where I : Iterator, F : FnMut<(I::Item,)>\n+{\n+    ...\n+}\n+\n+impl<I,F> Iterator for Map<A,B>,\n+    where I : Iterator<Item=A>,","path":"text/0000-fn-return-should-be-an-associated-type.md","position":55,"original_position":55,"commit_id":"60f9a2d47ffd83fcdebb9c29c637971059b673f4","original_commit_id":"60f9a2d47ffd83fcdebb9c29c637971059b673f4","user":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"body":"Should be `I: Iterator`?","created_at":"2015-01-15T00:46:42Z","updated_at":"2015-01-15T00:46:42Z","html_url":"https://github.com/rust-lang/rfcs/pull/587#discussion_r22983525","pull_request_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/587","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/22983525"},"html":{"href":"https://github.com/rust-lang/rfcs/pull/587#discussion_r22983525"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/587"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/587","id":27382090,"html_url":"https://github.com/rust-lang/rfcs/pull/587","diff_url":"https://github.com/rust-lang/rfcs/pull/587.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/587.patch","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/587","number":587,"state":"open","locked":false,"title":"Make return type of the `Fn` traits an associated type","user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"body":"Change the return type of the `Fn` traits to be an associated type.\r\n\r\n[Rendered form.](https://github.com/nikomatsakis/rfcs/blob/fn-return-assoc-type/text/0000-fn-return-should-be-an-associated-type.md)\r\n\r\ncc https://github.com/rust-lang/rust/issues/20871\r\ncc https://github.com/rust-lang/rust/pull/21019","created_at":"2015-01-14T20:47:57Z","updated_at":"2015-01-15T00:46:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16fda2c82b824b59cd2c2c325c4709fdafefe63a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/587/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/587/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/587/comments","statuses_url":"https://api.github.com/repos/rust-lang/rfcs/statuses/60f9a2d47ffd83fcdebb9c29c637971059b673f4","head":{"label":"nikomatsakis:fn-return-assoc-type","ref":"fn-return-assoc-type","sha":"60f9a2d47ffd83fcdebb9c29c637971059b673f4","user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"repo":{"id":17838433,"name":"rfcs","full_name":"nikomatsakis/rfcs","owner":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nikomatsakis/rfcs","description":"RFCs for changes to Rust","fork":true,"url":"https://api.github.com/repos/nikomatsakis/rfcs","forks_url":"https://api.github.com/repos/nikomatsakis/rfcs/forks","keys_url":"https://api.github.com/repos/nikomatsakis/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nikomatsakis/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nikomatsakis/rfcs/teams","hooks_url":"https://api.github.com/repos/nikomatsakis/rfcs/hooks","issue_events_url":"https://api.github.com/repos/nikomatsakis/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/nikomatsakis/rfcs/events","assignees_url":"https://api.github.com/repos/nikomatsakis/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/nikomatsakis/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/nikomatsakis/rfcs/tags","blobs_url":"https://api.github.com/repos/nikomatsakis/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nikomatsakis/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nikomatsakis/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/nikomatsakis/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nikomatsakis/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/nikomatsakis/rfcs/languages","stargazers_url":"https://api.github.com/repos/nikomatsakis/rfcs/stargazers","contributors_url":"https://api.github.com/repos/nikomatsakis/rfcs/contributors","subscribers_url":"https://api.github.com/repos/nikomatsakis/rfcs/subscribers","subscription_url":"https://api.github.com/repos/nikomatsakis/rfcs/subscription","commits_url":"https://api.github.com/repos/nikomatsakis/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/nikomatsakis/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/nikomatsakis/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/nikomatsakis/rfcs/issues/comments/{number}","contents_url":"https://api.github.com/repos/nikomatsakis/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/nikomatsakis/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nikomatsakis/rfcs/merges","archive_url":"https://api.github.com/repos/nikomatsakis/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nikomatsakis/rfcs/downloads","issues_url":"https://api.github.com/repos/nikomatsakis/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/nikomatsakis/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/nikomatsakis/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/nikomatsakis/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nikomatsakis/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/nikomatsakis/rfcs/releases{/id}","created_at":"2014-03-17T18:18:40Z","updated_at":"2014-10-06T17:51:08Z","pushed_at":"2015-01-14T20:59:27Z","git_url":"git://github.com/nikomatsakis/rfcs.git","ssh_url":"git@github.com:nikomatsakis/rfcs.git","clone_url":"https://github.com/nikomatsakis/rfcs.git","svn_url":"https://github.com/nikomatsakis/rfcs","homepage":"","size":1488,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"e0999be5aade97bb794d9f886bac31cfcb0f8a8d","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":17527989,"name":"rfcs","full_name":"rust-lang/rfcs","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/rfcs","description":"RFCs for changes to Rust","fork":false,"url":"https://api.github.com/repos/rust-lang/rfcs","forks_url":"https://api.github.com/repos/rust-lang/rfcs/forks","keys_url":"https://api.github.com/repos/rust-lang/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rfcs/teams","hooks_url":"https://api.github.com/repos/rust-lang/rfcs/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rfcs/events","assignees_url":"https://api.github.com/repos/rust-lang/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rfcs/tags","blobs_url":"https://api.github.com/repos/rust-lang/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rfcs/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rfcs/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rfcs/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rfcs/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rfcs/subscription","commits_url":"https://api.github.com/repos/rust-lang/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/{number}","contents_url":"https://api.github.com/repos/rust-lang/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rfcs/merges","archive_url":"https://api.github.com/repos/rust-lang/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rfcs/downloads","issues_url":"https://api.github.com/repos/rust-lang/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rfcs/releases{/id}","created_at":"2014-03-07T21:29:00Z","updated_at":"2015-01-13T11:38:10Z","pushed_at":"2015-01-13T00:31:18Z","git_url":"git://github.com/rust-lang/rfcs.git","ssh_url":"git@github.com:rust-lang/rfcs.git","clone_url":"https://github.com/rust-lang/rfcs.git","svn_url":"https://github.com/rust-lang/rfcs","homepage":"","size":6228,"stargazers_count":222,"watchers_count":222,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":142,"mirror_url":null,"open_issues_count":223,"forks":142,"open_issues":223,"watchers":222,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/587"},"html":{"href":"https://github.com/rust-lang/rfcs/pull/587"},"issue":{"href":"https://api.github.com/repos/rust-lang/rfcs/issues/587"},"comments":{"href":"https://api.github.com/repos/rust-lang/rfcs/issues/587/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/587/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/587/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rfcs/statuses/60f9a2d47ffd83fcdebb9c29c637971059b673f4"}}}}