{"action":"created","comment":{"url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/comments/83514558","pull_request_review_id":4355107,"id":83514558,"diff_hunk":"@@ -6,31 +6,201 @@\n # Summary\n [summary]: #summary\n \n-One para explanation of the feature.\n+Allow struct definitions to supply default values for individual fields,\n+and then allow those fields to be omitted from struct initialisation:\n+\n+```rust\n+struct Foo {\n+    a: &'static str,\n+    b: bool = true,\n+    c: i32,\n+}\n+\n+let foo = Foo {\n+    a: \"Hello\",\n+    c: 42,\n+}\n+```\n \n # Motivation\n [motivation]: #motivation\n \n-Why are we doing this? What use cases does it support? What is the expected outcome?\n+Today, Rust allows you to create an instance of a struct using a literal syntax.\n+This requires all fields in the struct be assigned a value, and can't be used\n+with private fields.\n+It can also be inconvenient for large structs that usually receive the same values.\n+\n+With the `..` syntax, values for missing fields can be taken from another struct.\n+This is convenient for using `Default` to override just a few values on initialisation:\n+\n+```rust\n+#[derive(Default)]\n+struct Foo {\n+    a: &'static str,\n+    b: bool,\n+    c: i32,\n+}\n+\n+let foo = Foo {\n+    a: \"Hello\",\n+    c: 42,\n+    ..Default::default()\n+}\n+```\n+\n+However, this still requires an already initialised struct after the `..`.","path":"default-fields/0000-default-fields.md","position":48,"original_position":48,"commit_id":"fbc32a4f1d923a405d9da011e4bdf87af72d4d38","original_commit_id":"fbc32a4f1d923a405d9da011e4bdf87af72d4d38","user":{"login":"leodasvacas","id":9885558,"avatar_url":"https://avatars.githubusercontent.com/u/9885558?v=3","gravatar_id":"","url":"https://api.github.com/users/leodasvacas","html_url":"https://github.com/leodasvacas","followers_url":"https://api.github.com/users/leodasvacas/followers","following_url":"https://api.github.com/users/leodasvacas/following{/other_user}","gists_url":"https://api.github.com/users/leodasvacas/gists{/gist_id}","starred_url":"https://api.github.com/users/leodasvacas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leodasvacas/subscriptions","organizations_url":"https://api.github.com/users/leodasvacas/orgs","repos_url":"https://api.github.com/users/leodasvacas/repos","events_url":"https://api.github.com/users/leodasvacas/events{/privacy}","received_events_url":"https://api.github.com/users/leodasvacas/received_events","type":"User","site_admin":false},"body":"Another drawback is that if the struct has a private field `..Default::default()` isn't valid.","created_at":"2016-10-14T22:55:45Z","updated_at":"2016-10-14T23:04:03Z","html_url":"https://github.com/nrc/mentor-rfcs/pull/7#discussion_r83514558","pull_request_url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/comments/83514558"},"html":{"href":"https://github.com/nrc/mentor-rfcs/pull/7#discussion_r83514558"},"pull_request":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7","id":88218770,"html_url":"https://github.com/nrc/mentor-rfcs/pull/7","diff_url":"https://github.com/nrc/mentor-rfcs/pull/7.diff","patch_url":"https://github.com/nrc/mentor-rfcs/pull/7.patch","issue_url":"https://api.github.com/repos/nrc/mentor-rfcs/issues/7","number":7,"state":"open","locked":false,"title":"Default values for struct fields","user":{"login":"KodrAus","id":6721458,"avatar_url":"https://avatars.githubusercontent.com/u/6721458?v=3","gravatar_id":"","url":"https://api.github.com/users/KodrAus","html_url":"https://github.com/KodrAus","followers_url":"https://api.github.com/users/KodrAus/followers","following_url":"https://api.github.com/users/KodrAus/following{/other_user}","gists_url":"https://api.github.com/users/KodrAus/gists{/gist_id}","starred_url":"https://api.github.com/users/KodrAus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KodrAus/subscriptions","organizations_url":"https://api.github.com/users/KodrAus/orgs","repos_url":"https://api.github.com/users/KodrAus/repos","events_url":"https://api.github.com/users/KodrAus/events{/privacy}","received_events_url":"https://api.github.com/users/KodrAus/received_events","type":"User","site_admin":false},"body":"RFC content for #1 \r\n\r\ncc: @nrc @leodasvacas","created_at":"2016-10-06T08:34:17Z","updated_at":"2016-10-14T23:04:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd0f13feb7cca7bf5c910c10d1f54902ba6041df","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7/commits","review_comments_url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7/comments","review_comment_url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nrc/mentor-rfcs/issues/7/comments","statuses_url":"https://api.github.com/repos/nrc/mentor-rfcs/statuses/fbc32a4f1d923a405d9da011e4bdf87af72d4d38","head":{"label":"KodrAus:master","ref":"master","sha":"fbc32a4f1d923a405d9da011e4bdf87af72d4d38","user":{"login":"KodrAus","id":6721458,"avatar_url":"https://avatars.githubusercontent.com/u/6721458?v=3","gravatar_id":"","url":"https://api.github.com/users/KodrAus","html_url":"https://github.com/KodrAus","followers_url":"https://api.github.com/users/KodrAus/followers","following_url":"https://api.github.com/users/KodrAus/following{/other_user}","gists_url":"https://api.github.com/users/KodrAus/gists{/gist_id}","starred_url":"https://api.github.com/users/KodrAus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KodrAus/subscriptions","organizations_url":"https://api.github.com/users/KodrAus/orgs","repos_url":"https://api.github.com/users/KodrAus/repos","events_url":"https://api.github.com/users/KodrAus/events{/privacy}","received_events_url":"https://api.github.com/users/KodrAus/received_events","type":"User","site_admin":false},"repo":{"id":70130075,"name":"mentor-rfcs","full_name":"KodrAus/mentor-rfcs","owner":{"login":"KodrAus","id":6721458,"avatar_url":"https://avatars.githubusercontent.com/u/6721458?v=3","gravatar_id":"","url":"https://api.github.com/users/KodrAus","html_url":"https://github.com/KodrAus","followers_url":"https://api.github.com/users/KodrAus/followers","following_url":"https://api.github.com/users/KodrAus/following{/other_user}","gists_url":"https://api.github.com/users/KodrAus/gists{/gist_id}","starred_url":"https://api.github.com/users/KodrAus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KodrAus/subscriptions","organizations_url":"https://api.github.com/users/KodrAus/orgs","repos_url":"https://api.github.com/users/KodrAus/repos","events_url":"https://api.github.com/users/KodrAus/events{/privacy}","received_events_url":"https://api.github.com/users/KodrAus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KodrAus/mentor-rfcs","description":"A place to improve your RFC writing skills and collaborate on writing RFCs","fork":true,"url":"https://api.github.com/repos/KodrAus/mentor-rfcs","forks_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/forks","keys_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/teams","hooks_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/hooks","issue_events_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/events","assignees_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/tags","blobs_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/languages","stargazers_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/stargazers","contributors_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/contributors","subscribers_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/subscribers","subscription_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/subscription","commits_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/merges","archive_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/downloads","issues_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/labels{/name}","releases_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/releases{/id}","deployments_url":"https://api.github.com/repos/KodrAus/mentor-rfcs/deployments","created_at":"2016-10-06T06:54:03Z","updated_at":"2016-10-06T05:10:15Z","pushed_at":"2016-10-14T05:14:51Z","git_url":"git://github.com/KodrAus/mentor-rfcs.git","ssh_url":"git@github.com:KodrAus/mentor-rfcs.git","clone_url":"https://github.com/KodrAus/mentor-rfcs.git","svn_url":"https://github.com/KodrAus/mentor-rfcs","homepage":null,"size":9,"stargazers_count":0,"watchers_count":0,"language":null,"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":"nrc:master","ref":"master","sha":"ad5450717cf73610ed98ffea3586bb43660a4c38","user":{"login":"nrc","id":762626,"avatar_url":"https://avatars.githubusercontent.com/u/762626?v=3","gravatar_id":"","url":"https://api.github.com/users/nrc","html_url":"https://github.com/nrc","followers_url":"https://api.github.com/users/nrc/followers","following_url":"https://api.github.com/users/nrc/following{/other_user}","gists_url":"https://api.github.com/users/nrc/gists{/gist_id}","starred_url":"https://api.github.com/users/nrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrc/subscriptions","organizations_url":"https://api.github.com/users/nrc/orgs","repos_url":"https://api.github.com/users/nrc/repos","events_url":"https://api.github.com/users/nrc/events{/privacy}","received_events_url":"https://api.github.com/users/nrc/received_events","type":"User","site_admin":false},"repo":{"id":70003146,"name":"mentor-rfcs","full_name":"nrc/mentor-rfcs","owner":{"login":"nrc","id":762626,"avatar_url":"https://avatars.githubusercontent.com/u/762626?v=3","gravatar_id":"","url":"https://api.github.com/users/nrc","html_url":"https://github.com/nrc","followers_url":"https://api.github.com/users/nrc/followers","following_url":"https://api.github.com/users/nrc/following{/other_user}","gists_url":"https://api.github.com/users/nrc/gists{/gist_id}","starred_url":"https://api.github.com/users/nrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrc/subscriptions","organizations_url":"https://api.github.com/users/nrc/orgs","repos_url":"https://api.github.com/users/nrc/repos","events_url":"https://api.github.com/users/nrc/events{/privacy}","received_events_url":"https://api.github.com/users/nrc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nrc/mentor-rfcs","description":"A place to improve your RFC writing skills and collaborate on writing RFCs","fork":false,"url":"https://api.github.com/repos/nrc/mentor-rfcs","forks_url":"https://api.github.com/repos/nrc/mentor-rfcs/forks","keys_url":"https://api.github.com/repos/nrc/mentor-rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nrc/mentor-rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nrc/mentor-rfcs/teams","hooks_url":"https://api.github.com/repos/nrc/mentor-rfcs/hooks","issue_events_url":"https://api.github.com/repos/nrc/mentor-rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/nrc/mentor-rfcs/events","assignees_url":"https://api.github.com/repos/nrc/mentor-rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/nrc/mentor-rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/nrc/mentor-rfcs/tags","blobs_url":"https://api.github.com/repos/nrc/mentor-rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nrc/mentor-rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nrc/mentor-rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/nrc/mentor-rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nrc/mentor-rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/nrc/mentor-rfcs/languages","stargazers_url":"https://api.github.com/repos/nrc/mentor-rfcs/stargazers","contributors_url":"https://api.github.com/repos/nrc/mentor-rfcs/contributors","subscribers_url":"https://api.github.com/repos/nrc/mentor-rfcs/subscribers","subscription_url":"https://api.github.com/repos/nrc/mentor-rfcs/subscription","commits_url":"https://api.github.com/repos/nrc/mentor-rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/nrc/mentor-rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/nrc/mentor-rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/nrc/mentor-rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/nrc/mentor-rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/nrc/mentor-rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nrc/mentor-rfcs/merges","archive_url":"https://api.github.com/repos/nrc/mentor-rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nrc/mentor-rfcs/downloads","issues_url":"https://api.github.com/repos/nrc/mentor-rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/nrc/mentor-rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/nrc/mentor-rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/nrc/mentor-rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nrc/mentor-rfcs/labels{/name}","releases_url":"https://api.github.com/repos/nrc/mentor-rfcs/releases{/id}","deployments_url":"https://api.github.com/repos/nrc/mentor-rfcs/deployments","created_at":"2016-10-04T20:23:56Z","updated_at":"2016-10-06T10:35:17Z","pushed_at":"2016-10-14T05:14:51Z","git_url":"git://github.com/nrc/mentor-rfcs.git","ssh_url":"git@github.com:nrc/mentor-rfcs.git","clone_url":"https://github.com/nrc/mentor-rfcs.git","svn_url":"https://github.com/nrc/mentor-rfcs","homepage":null,"size":3,"stargazers_count":9,"watchers_count":9,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7"},"html":{"href":"https://github.com/nrc/mentor-rfcs/pull/7"},"issue":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/issues/7"},"comments":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/nrc/mentor-rfcs/statuses/fbc32a4f1d923a405d9da011e4bdf87af72d4d38"}}}}
{"actor":{"display_login":"leodasvacas"}}