{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/22899472","id":22899472,"diff_hunk":"@@ -56,11 +58,115 @@ other parameter. Because we know it's a `Circle`, we can access the `radius`\n just like we would with any other struct. An import of π and some\n multiplications later, and we have our area.\n \n+## Chaining method calls\n+\n+So, now we know how to call a method, such as `foo.bar()`. But what about our\n+original example, `foo.bar().baz()`? This is called 'method chaining', and we\n+can do it by returning `self`.\n+\n+```\n+struct Circle {\n+    x: f64,\n+    y: f64,\n+    radius: f64,\n+}\n+\n+impl Circle {\n+    fn area(&self) -> f64 {\n+        std::f64::consts::PI * (self.radius * self.radius)\n+    }\n+\n+    fn grow(&self) -> Circle {\n+        Circle { x: self.x, y: self.y, radius: (self.radius * 10.0) }\n+    }\n+}\n+\n+fn main() {\n+    let c = Circle { x: 0.0, y: 0.0, radius: 2.0 };\n+    println!(\"{}\", c.area());\n+\n+    let d = c.grow().area();\n+    println!(\"{}\", d);\n+}\n+```\n+\n+Check the return type:\n+\n+```\n+# struct Circle;\n+# impl Circle {\n+fn grow(&self) -> Circle {\n+# Circle } }\n+```\n+\n+We just say we're returning a `Circle`. With this, we can grow a new circle\n+that's twice as big as the old one. But what if we didn't want to make a new\n+Circle, and instead change the old one? There's a pattern where this is\n+commonly used: the builder pattern.\n+\n+## The Builder Pattern\n+\n+Let's say that we want our users to be able to create Circles, but we will\n+allow them to only set the properties they care about. Otherwise, the `x`\n+and `y` attributes will be `0.0`, and the `radius` will be `1.0`. Rust doesn't\n+have method overloading, named arguments, or variable arguments. We employ\n+the builder pattern instead. It looks like this:\n+\n+```\n+struct Circle {\n+    x: f64,\n+    y: f64,\n+    radius: f64,\n+}\n+\n+impl Circle {\n+    fn x(&mut self, x: f64) -> &mut Circle {","path":"src/doc/trpl/method-syntax.md","position":75,"original_position":75,"commit_id":"82f43c7369b9ef3586b849a734d35cc0403ded76","original_commit_id":"82f43c7369b9ef3586b849a734d35cc0403ded76","user":{"login":"HeroesGrave","id":1934172,"avatar_url":"https://avatars.githubusercontent.com/u/1934172?v=3","gravatar_id":"","url":"https://api.github.com/users/HeroesGrave","html_url":"https://github.com/HeroesGrave","followers_url":"https://api.github.com/users/HeroesGrave/followers","following_url":"https://api.github.com/users/HeroesGrave/following{/other_user}","gists_url":"https://api.github.com/users/HeroesGrave/gists{/gist_id}","starred_url":"https://api.github.com/users/HeroesGrave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HeroesGrave/subscriptions","organizations_url":"https://api.github.com/users/HeroesGrave/orgs","repos_url":"https://api.github.com/users/HeroesGrave/repos","events_url":"https://api.github.com/users/HeroesGrave/events{/privacy}","received_events_url":"https://api.github.com/users/HeroesGrave/received_events","type":"User","site_admin":false},"body":"If you're referring to the \"Advanced Builder Pattern\" section then it's missing.\r\nIf not then I don't know what I missed.\r\n\r\n```rust\r\nlet circle: Circle = Circle::new().radius(5.0).coordinate(10.0);\r\n```\r\nseems a lot more usable to me than\r\n```rust\r\nlet mut circle_builder = CircleBuilder::new();\r\ncircle_builder.radius(5.0).coordinate(10.0);\r\nlet circle: Circle = circle_builder.finalise();\r\n```","created_at":"2015-01-13T22:08:31Z","updated_at":"2015-01-13T22:08:31Z","html_url":"https://github.com/rust-lang/rust/pull/21108#discussion_r22899472","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/21108","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/22899472"},"html":{"href":"https://github.com/rust-lang/rust/pull/21108#discussion_r22899472"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/21108"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/21108","id":27299839,"html_url":"https://github.com/rust-lang/rust/pull/21108","diff_url":"https://github.com/rust-lang/rust/pull/21108.diff","patch_url":"https://github.com/rust-lang/rust/pull/21108.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/21108","number":21108,"state":"open","locked":false,"title":"Soup up 'method syntax' chapter of the Book","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":"Fixes #16969","created_at":"2015-01-13T20:00:51Z","updated_at":"2015-01-13T22:08:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"069bc3f855e33fce759dbecbcc8da1b1818770f5","assignee":{"login":"pcwalton","id":157897,"avatar_url":"https://avatars.githubusercontent.com/u/157897?v=3","gravatar_id":"","url":"https://api.github.com/users/pcwalton","html_url":"https://github.com/pcwalton","followers_url":"https://api.github.com/users/pcwalton/followers","following_url":"https://api.github.com/users/pcwalton/following{/other_user}","gists_url":"https://api.github.com/users/pcwalton/gists{/gist_id}","starred_url":"https://api.github.com/users/pcwalton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcwalton/subscriptions","organizations_url":"https://api.github.com/users/pcwalton/orgs","repos_url":"https://api.github.com/users/pcwalton/repos","events_url":"https://api.github.com/users/pcwalton/events{/privacy}","received_events_url":"https://api.github.com/users/pcwalton/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/21108/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/21108/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/21108/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/82f43c7369b9ef3586b849a734d35cc0403ded76","head":{"label":"steveklabnik:gh16969","ref":"gh16969","sha":"82f43c7369b9ef3586b849a734d35cc0403ded76","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},"repo":{"id":7349289,"name":"rust","full_name":"steveklabnik/rust","owner":{"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},"private":false,"html_url":"https://github.com/steveklabnik/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/steveklabnik/rust","forks_url":"https://api.github.com/repos/steveklabnik/rust/forks","keys_url":"https://api.github.com/repos/steveklabnik/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/steveklabnik/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/steveklabnik/rust/teams","hooks_url":"https://api.github.com/repos/steveklabnik/rust/hooks","issue_events_url":"https://api.github.com/repos/steveklabnik/rust/issues/events{/number}","events_url":"https://api.github.com/repos/steveklabnik/rust/events","assignees_url":"https://api.github.com/repos/steveklabnik/rust/assignees{/user}","branches_url":"https://api.github.com/repos/steveklabnik/rust/branches{/branch}","tags_url":"https://api.github.com/repos/steveklabnik/rust/tags","blobs_url":"https://api.github.com/repos/steveklabnik/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/steveklabnik/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/steveklabnik/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/steveklabnik/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/steveklabnik/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/steveklabnik/rust/languages","stargazers_url":"https://api.github.com/repos/steveklabnik/rust/stargazers","contributors_url":"https://api.github.com/repos/steveklabnik/rust/contributors","subscribers_url":"https://api.github.com/repos/steveklabnik/rust/subscribers","subscription_url":"https://api.github.com/repos/steveklabnik/rust/subscription","commits_url":"https://api.github.com/repos/steveklabnik/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/steveklabnik/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/steveklabnik/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/steveklabnik/rust/issues/comments/{number}","contents_url":"https://api.github.com/repos/steveklabnik/rust/contents/{+path}","compare_url":"https://api.github.com/repos/steveklabnik/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/steveklabnik/rust/merges","archive_url":"https://api.github.com/repos/steveklabnik/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/steveklabnik/rust/downloads","issues_url":"https://api.github.com/repos/steveklabnik/rust/issues{/number}","pulls_url":"https://api.github.com/repos/steveklabnik/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/steveklabnik/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/steveklabnik/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/steveklabnik/rust/labels{/name}","releases_url":"https://api.github.com/repos/steveklabnik/rust/releases{/id}","created_at":"2012-12-28T03:07:04Z","updated_at":"2015-01-12T15:59:52Z","pushed_at":"2015-01-13T20:56:41Z","git_url":"git://github.com/steveklabnik/rust.git","ssh_url":"git@github.com:steveklabnik/rust.git","clone_url":"https://github.com/steveklabnik/rust.git","svn_url":"https://github.com/steveklabnik/rust","homepage":"http://www.rust-lang.org","size":218434,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"e94a9f033eb79b3b4fb037722366644650e8e16c","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}","created_at":"2010-06-16T20:39:03Z","updated_at":"2015-01-13T22:07:21Z","pushed_at":"2015-01-13T21:29:01Z","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":431387,"stargazers_count":8752,"watchers_count":8752,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1689,"mirror_url":null,"open_issues_count":2391,"forks":1689,"open_issues":2391,"watchers":8752,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/21108"},"html":{"href":"https://github.com/rust-lang/rust/pull/21108"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/21108"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/21108/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/21108/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/21108/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/82f43c7369b9ef3586b849a734d35cc0403ded76"}}}}