{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/866","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/866/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/866/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/866/events","html_url":"https://github.com/rust-lang/rfcs/pull/866","id":57754037,"number":866,"title":"New struct syntax","user":{"login":"phaux","id":1270987,"avatar_url":"https://avatars.githubusercontent.com/u/1270987?v=3","gravatar_id":"","url":"https://api.github.com/users/phaux","html_url":"https://github.com/phaux","followers_url":"https://api.github.com/users/phaux/followers","following_url":"https://api.github.com/users/phaux/following{/other_user}","gists_url":"https://api.github.com/users/phaux/gists{/gist_id}","starred_url":"https://api.github.com/users/phaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phaux/subscriptions","organizations_url":"https://api.github.com/users/phaux/orgs","repos_url":"https://api.github.com/users/phaux/repos","events_url":"https://api.github.com/users/phaux/events{/privacy}","received_events_url":"https://api.github.com/users/phaux/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":42,"created_at":"2015-02-16T00:30:54Z","updated_at":"2015-02-19T11:07:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/866","html_url":"https://github.com/rust-lang/rfcs/pull/866","diff_url":"https://github.com/rust-lang/rfcs/pull/866.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/866.patch"},"body":"`Foo{x=>1, y=>2}` struct syntax. Hopefully an improvement over #841. I tried to explain the implementation details more thoroughly.\r\n\r\n[Rendered](https://github.com/phaux/rfcs/blob/new-struct-syntax/text/0000-new-struct-syntax.md)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/75034842","html_url":"https://github.com/rust-lang/rfcs/pull/866#issuecomment-75034842","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/866","id":75034842,"user":{"login":"phaux","id":1270987,"avatar_url":"https://avatars.githubusercontent.com/u/1270987?v=3","gravatar_id":"","url":"https://api.github.com/users/phaux","html_url":"https://github.com/phaux","followers_url":"https://api.github.com/users/phaux/followers","following_url":"https://api.github.com/users/phaux/following{/other_user}","gists_url":"https://api.github.com/users/phaux/gists{/gist_id}","starred_url":"https://api.github.com/users/phaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phaux/subscriptions","organizations_url":"https://api.github.com/users/phaux/orgs","repos_url":"https://api.github.com/users/phaux/repos","events_url":"https://api.github.com/users/phaux/events{/privacy}","received_events_url":"https://api.github.com/users/phaux/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T11:07:40Z","updated_at":"2015-02-19T11:07:40Z","body":"> I am not really interested in making changes of this magnitude without a very strong justification.\r\n\r\nOkay, so let me reiterate over what **won't** be possible without new syntax:\r\n\r\n-\tEasy distinction between anonymous single-value struct and a code block with a type ascribed variable. Might be resolved similarly to how we differentiate single value tuples from expressions. (thanks @mandel59)\r\n\r\n\t```rust\r\n\tlet foo1 = { value: Foo }; // block\r\n\tlet foo2 = { field: foo1, }; // struct\r\n\t\r\n\t// with this RFC:\r\n\tlet foo1 = { value: Foo }; // block\r\n\tlet foo2 = { field => foo1 }; // struct\r\n\t```\r\n\r\n-\tPossibility to pattern-match and bind type ascribed struct field to a variable with the same name as the struct field, without repeating the name 2 times.\r\n\r\n\t```rust\r\n\t// bind to other name:\r\n\tlet {x: point_x, y: point_y} = get_point();\r\n\t\r\n\t// bind to other name and ascribe:\r\n\tlet {x: point_x: f32, y: point_y: f32} = get_point();\r\n\t\r\n\t// bind to same name:\r\n\tlet {x, y} = get_point();\r\n\t\r\n\t// bind to same name and ascribe:\r\n\t//<not possible>\r\n\t\r\n\t// with this RFC\r\n\t\r\n\t// bind to other name:\r\n\tlet {x => point_x, y => point_y} = get_point();\r\n\t\r\n\t// bind to other name and ascribe:\r\n\tlet {x => point_x: f32, y => point_y: f32} = get_point();\r\n\t\r\n\t// bind to same name:\r\n\tlet {x, y} = get_point();\r\n\t\r\n\t// bind to same name and ascribe:\r\n\tlet {x: f32, y: f32} = get_point();\r\n\t```\r\n\r\n-\tNamed arguments: possibility to reuse struct syntax within function brackets. Could be resolved by not having named arguments *per se*, but using anonymous structs for this purpose.\r\n\r\n\t```rust\r\n\tdraw_rect({x: x1: f32, y: y1, w: x2 - x1, h: y2 - y1});\r\n\t\r\n\t// with this RFC\r\n\tdraw_rect(x => x1: f32, y => y1, w => x2 - x1, h => y2 - y1});\r\n\t// or\r\n\tdraw_rect((x,y,w,h) => (x1: f32, y1, x2 - x1, y2 - y1));\r\n\t```"}}