{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/comments/31883238","id":31883238,"diff_hunk":"@@ -8,26 +8,30 @@ struct Inch;\n struct Mm;\n \n /// Length is phantom type with hidden parameter `Unit`\n+/// f64 already implements the Clone and Copy traits\n #[derive(Debug, Clone, Copy)]\n-struct Length<Unit, T>(T,PhantomData<Unit>);\n+struct Length<Unit>(f64,PhantomData<Unit>);\n \n-// This is similar to the header except `T` must also\n-// implement `Clone` and `Copy.\n-impl<Unit, T> Add<Length<Unit, T>> for Length<Unit, T> where\n-    T: Add<T, Output=T> + Clone + Copy {\n-    type Output = Length<Unit, T>;\n+/// The Add trait defines the behavior of the `+` operator\n+impl<Unit> Add for Length<Unit> {\n+     type Output = Length<Unit>;\n \n-    fn add(self, r: Length<Unit, T>) -> Length<Unit, T> {\n-        Length(self.0 + r.0, PhantomData)\n+\t// add() returns a new Length struct containing the sum\n+    fn add(self, rhs: Length<Unit>) -> Length<Unit> {\n+\t\t// `+` calls the Add implementation for f64\n+        Length(self.0 + rhs.0, PhantomData)\n     }\n }\n \n fn main() {\n     // Specialize one_foot to have hidden parameter `Inch`\n-    let one_foot:  Length<Inch, f32> = Length(12.0, PhantomData);\n+    let one_foot:  Length<Inch> = Length(12.0, PhantomData);\n     // one_meter has hidden parameter `Mm`\n-    let one_meter: Length<Mm, f32>   = Length(1000.0, PhantomData);\n+    let one_meter: Length<Mm>   = Length(1000.0, PhantomData);\n \n+\t// `+` calls the add() method we implemented for Length<Unit>\n+\t// Since Length implements Clone + Copy, add() does not consume\n+\t// one_foot and one_meter but makes a copy of them in `self` and `rhs`","path":"examples/generics/phantom/testcase_units/units.rs","position":37,"original_position":37,"commit_id":"a8c37f0283bc194b184f58dcd2aa5534acc4a65c","original_commit_id":"a8c37f0283bc194b184f58dcd2aa5534acc4a65c","user":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"body":"`one_foot` and `one_meter` in backticks","created_at":"2015-06-08T01:04:03Z","updated_at":"2015-06-08T01:04:03Z","html_url":"https://github.com/rust-lang/rust-by-example/pull/583#discussion_r31883238","pull_request_url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/comments/31883238"},"html":{"href":"https://github.com/rust-lang/rust-by-example/pull/583#discussion_r31883238"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583","id":36581576,"html_url":"https://github.com/rust-lang/rust-by-example/pull/583","diff_url":"https://github.com/rust-lang/rust-by-example/pull/583.diff","patch_url":"https://github.com/rust-lang/rust-by-example/pull/583.patch","issue_url":"https://api.github.com/repos/rust-lang/rust-by-example/issues/583","number":583,"state":"open","locked":false,"title":"generics/phantom/testcase_units: alleviate the syntactical heaviness of the types and bounds","user":{"login":"Letheed","id":5330692,"avatar_url":"https://avatars.githubusercontent.com/u/5330692?v=3","gravatar_id":"","url":"https://api.github.com/users/Letheed","html_url":"https://github.com/Letheed","followers_url":"https://api.github.com/users/Letheed/followers","following_url":"https://api.github.com/users/Letheed/following{/other_user}","gists_url":"https://api.github.com/users/Letheed/gists{/gist_id}","starred_url":"https://api.github.com/users/Letheed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Letheed/subscriptions","organizations_url":"https://api.github.com/users/Letheed/orgs","repos_url":"https://api.github.com/users/Letheed/repos","events_url":"https://api.github.com/users/Letheed/events{/privacy}","received_events_url":"https://api.github.com/users/Letheed/received_events","type":"User","site_admin":false},"body":"I tried to retain the information on the bounds in a few comments because it does matter.\r\nClose #582","created_at":"2015-05-31T12:42:48Z","updated_at":"2015-06-08T01:04:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"825302296d63afdb07969b0eb75cad5408e15273","assignee":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust-by-example/issues/583/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust-by-example/statuses/a8c37f0283bc194b184f58dcd2aa5534acc4a65c","head":{"label":"Letheed:master","ref":"master","sha":"a8c37f0283bc194b184f58dcd2aa5534acc4a65c","user":{"login":"Letheed","id":5330692,"avatar_url":"https://avatars.githubusercontent.com/u/5330692?v=3","gravatar_id":"","url":"https://api.github.com/users/Letheed","html_url":"https://github.com/Letheed","followers_url":"https://api.github.com/users/Letheed/followers","following_url":"https://api.github.com/users/Letheed/following{/other_user}","gists_url":"https://api.github.com/users/Letheed/gists{/gist_id}","starred_url":"https://api.github.com/users/Letheed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Letheed/subscriptions","organizations_url":"https://api.github.com/users/Letheed/orgs","repos_url":"https://api.github.com/users/Letheed/repos","events_url":"https://api.github.com/users/Letheed/events{/privacy}","received_events_url":"https://api.github.com/users/Letheed/received_events","type":"User","site_admin":false},"repo":{"id":36599325,"name":"rust-by-example","full_name":"Letheed/rust-by-example","owner":{"login":"Letheed","id":5330692,"avatar_url":"https://avatars.githubusercontent.com/u/5330692?v=3","gravatar_id":"","url":"https://api.github.com/users/Letheed","html_url":"https://github.com/Letheed","followers_url":"https://api.github.com/users/Letheed/followers","following_url":"https://api.github.com/users/Letheed/following{/other_user}","gists_url":"https://api.github.com/users/Letheed/gists{/gist_id}","starred_url":"https://api.github.com/users/Letheed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Letheed/subscriptions","organizations_url":"https://api.github.com/users/Letheed/orgs","repos_url":"https://api.github.com/users/Letheed/repos","events_url":"https://api.github.com/users/Letheed/events{/privacy}","received_events_url":"https://api.github.com/users/Letheed/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Letheed/rust-by-example","description":"Learn Rust with examples (Live code editor included)","fork":true,"url":"https://api.github.com/repos/Letheed/rust-by-example","forks_url":"https://api.github.com/repos/Letheed/rust-by-example/forks","keys_url":"https://api.github.com/repos/Letheed/rust-by-example/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Letheed/rust-by-example/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Letheed/rust-by-example/teams","hooks_url":"https://api.github.com/repos/Letheed/rust-by-example/hooks","issue_events_url":"https://api.github.com/repos/Letheed/rust-by-example/issues/events{/number}","events_url":"https://api.github.com/repos/Letheed/rust-by-example/events","assignees_url":"https://api.github.com/repos/Letheed/rust-by-example/assignees{/user}","branches_url":"https://api.github.com/repos/Letheed/rust-by-example/branches{/branch}","tags_url":"https://api.github.com/repos/Letheed/rust-by-example/tags","blobs_url":"https://api.github.com/repos/Letheed/rust-by-example/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Letheed/rust-by-example/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Letheed/rust-by-example/git/refs{/sha}","trees_url":"https://api.github.com/repos/Letheed/rust-by-example/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Letheed/rust-by-example/statuses/{sha}","languages_url":"https://api.github.com/repos/Letheed/rust-by-example/languages","stargazers_url":"https://api.github.com/repos/Letheed/rust-by-example/stargazers","contributors_url":"https://api.github.com/repos/Letheed/rust-by-example/contributors","subscribers_url":"https://api.github.com/repos/Letheed/rust-by-example/subscribers","subscription_url":"https://api.github.com/repos/Letheed/rust-by-example/subscription","commits_url":"https://api.github.com/repos/Letheed/rust-by-example/commits{/sha}","git_commits_url":"https://api.github.com/repos/Letheed/rust-by-example/git/commits{/sha}","comments_url":"https://api.github.com/repos/Letheed/rust-by-example/comments{/number}","issue_comment_url":"https://api.github.com/repos/Letheed/rust-by-example/issues/comments{/number}","contents_url":"https://api.github.com/repos/Letheed/rust-by-example/contents/{+path}","compare_url":"https://api.github.com/repos/Letheed/rust-by-example/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Letheed/rust-by-example/merges","archive_url":"https://api.github.com/repos/Letheed/rust-by-example/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Letheed/rust-by-example/downloads","issues_url":"https://api.github.com/repos/Letheed/rust-by-example/issues{/number}","pulls_url":"https://api.github.com/repos/Letheed/rust-by-example/pulls{/number}","milestones_url":"https://api.github.com/repos/Letheed/rust-by-example/milestones{/number}","notifications_url":"https://api.github.com/repos/Letheed/rust-by-example/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Letheed/rust-by-example/labels{/name}","releases_url":"https://api.github.com/repos/Letheed/rust-by-example/releases{/id}","created_at":"2015-05-31T11:03:05Z","updated_at":"2015-05-31T11:03:06Z","pushed_at":"2015-06-03T00:39:09Z","git_url":"git://github.com/Letheed/rust-by-example.git","ssh_url":"git@github.com:Letheed/rust-by-example.git","clone_url":"https://github.com/Letheed/rust-by-example.git","svn_url":"https://github.com/Letheed/rust-by-example","homepage":"http://rustbyexample.com","size":1980,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"5dc78648cc8e64123498ddf01222cb48855fa597","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":19126114,"name":"rust-by-example","full_name":"rust-lang/rust-by-example","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-by-example","description":"Learn Rust with examples (Live code editor included)","fork":false,"url":"https://api.github.com/repos/rust-lang/rust-by-example","forks_url":"https://api.github.com/repos/rust-lang/rust-by-example/forks","keys_url":"https://api.github.com/repos/rust-lang/rust-by-example/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust-by-example/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust-by-example/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust-by-example/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust-by-example/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust-by-example/events","assignees_url":"https://api.github.com/repos/rust-lang/rust-by-example/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust-by-example/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust-by-example/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust-by-example/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust-by-example/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust-by-example/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust-by-example/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust-by-example/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust-by-example/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust-by-example/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust-by-example/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust-by-example/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust-by-example/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust-by-example/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust-by-example/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust-by-example/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust-by-example/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust-by-example/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust-by-example/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust-by-example/merges","archive_url":"https://api.github.com/repos/rust-lang/rust-by-example/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust-by-example/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust-by-example/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust-by-example/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust-by-example/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust-by-example/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust-by-example/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust-by-example/releases{/id}","created_at":"2014-04-24T22:22:40Z","updated_at":"2015-06-07T15:20:13Z","pushed_at":"2015-06-08T00:59:13Z","git_url":"git://github.com/rust-lang/rust-by-example.git","ssh_url":"git@github.com:rust-lang/rust-by-example.git","clone_url":"https://github.com/rust-lang/rust-by-example.git","svn_url":"https://github.com/rust-lang/rust-by-example","homepage":"http://rustbyexample.com","size":50608,"stargazers_count":1696,"watchers_count":1696,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":222,"mirror_url":null,"open_issues_count":71,"forks":222,"open_issues":71,"watchers":1696,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583"},"html":{"href":"https://github.com/rust-lang/rust-by-example/pull/583"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/issues/583"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/issues/583/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/pulls/583/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust-by-example/statuses/a8c37f0283bc194b184f58dcd2aa5534acc4a65c"}}}}