{"action":"created","comment":{"url":"https://api.github.com/repos/google/flatbuffers/pulls/comments/234836481","pull_request_review_id":176563875,"id":234836481,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDgzNjQ4MQ==","diff_hunk":"@@ -1327,12 +1327,21 @@ class RustGenerator : public BaseGenerator {\n         code_ += \"  #[allow(non_snake_case)]\";\n         code_ += \"  pub fn {{FIELD_NAME}}_as_{{U_ELEMENT_NAME}}(&'a self) -> \"\n                  \"Option<{{U_ELEMENT_TABLE_TYPE}}> {\";\n-        code_ += \"    if self.{{FIELD_NAME}}_type() == {{U_ELEMENT_ENUM_TYPE}} {\";\n-        code_ += \"      self.{{FIELD_NAME}}().map(|u| \"\n-                 \"{{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))\";\n-        code_ += \"    } else {\";\n-        code_ += \"      None\";\n-        code_ += \"    }\";\n+\n+        if (field.required) {\n+          code_ += \"      None\";\n+        } else {\n+          code_ += \"    if self.{{FIELD_NAME}}_type() == {{U_ELEMENT_ENUM_TYPE}} {\";\n+          code_ += \"      self.{{FIELD_NAME}}().map(|u| \"","path":"src/idl_gen_rust.cpp","position":24,"original_position":24,"commit_id":"5fe6c70d36c2aa691ce24eafe3dc6f9a54c18655","original_commit_id":"5fe6c70d36c2aa691ce24eafe3dc6f9a54c18655","user":{"login":"rw","id":21367,"node_id":"MDQ6VXNlcjIxMzY3","avatar_url":"https://avatars2.githubusercontent.com/u/21367?v=4","gravatar_id":"","url":"https://api.github.com/users/rw","html_url":"https://github.com/rw","followers_url":"https://api.github.com/users/rw/followers","following_url":"https://api.github.com/users/rw/following{/other_user}","gists_url":"https://api.github.com/users/rw/gists{/gist_id}","starred_url":"https://api.github.com/users/rw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rw/subscriptions","organizations_url":"https://api.github.com/users/rw/orgs","repos_url":"https://api.github.com/users/rw/repos","events_url":"https://api.github.com/users/rw/events{/privacy}","received_events_url":"https://api.github.com/users/rw/received_events","type":"User","site_admin":false},"body":"This is where the conditional on `required` needs to be: if the field is `required`, don't do the `Option` `map`.","created_at":"2018-11-20T00:53:43Z","updated_at":"2018-11-20T00:53:49Z","html_url":"https://github.com/google/flatbuffers/pull/5056#discussion_r234836481","pull_request_url":"https://api.github.com/repos/google/flatbuffers/pulls/5056","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/google/flatbuffers/pulls/comments/234836481"},"html":{"href":"https://github.com/google/flatbuffers/pull/5056#discussion_r234836481"},"pull_request":{"href":"https://api.github.com/repos/google/flatbuffers/pulls/5056"}}},"pull_request":{"url":"https://api.github.com/repos/google/flatbuffers/pulls/5056","id":232075797,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyMDc1Nzk3","html_url":"https://github.com/google/flatbuffers/pull/5056","diff_url":"https://github.com/google/flatbuffers/pull/5056.diff","patch_url":"https://github.com/google/flatbuffers/pull/5056.patch","issue_url":"https://api.github.com/repos/google/flatbuffers/issues/5056","number":5056,"state":"open","locked":false,"title":"Rust - add validation for typed union accessors","user":{"login":"Tommytrg","id":24905681,"node_id":"MDQ6VXNlcjI0OTA1Njgx","avatar_url":"https://avatars0.githubusercontent.com/u/24905681?v=4","gravatar_id":"","url":"https://api.github.com/users/Tommytrg","html_url":"https://github.com/Tommytrg","followers_url":"https://api.github.com/users/Tommytrg/followers","following_url":"https://api.github.com/users/Tommytrg/following{/other_user}","gists_url":"https://api.github.com/users/Tommytrg/gists{/gist_id}","starred_url":"https://api.github.com/users/Tommytrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tommytrg/subscriptions","organizations_url":"https://api.github.com/users/Tommytrg/orgs","repos_url":"https://api.github.com/users/Tommytrg/repos","events_url":"https://api.github.com/users/Tommytrg/events{/privacy}","received_events_url":"https://api.github.com/users/Tommytrg/received_events","type":"User","site_admin":false},"body":"Follow @rw suggestion to fix #5055 that was discussed in #4967.","created_at":"2018-11-19T18:48:55Z","updated_at":"2018-11-20T00:53:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ae88ddaadb0c8937ceb821389a8a47b7debc2c8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/flatbuffers/pulls/5056/commits","review_comments_url":"https://api.github.com/repos/google/flatbuffers/pulls/5056/comments","review_comment_url":"https://api.github.com/repos/google/flatbuffers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/5056/comments","statuses_url":"https://api.github.com/repos/google/flatbuffers/statuses/5fe6c70d36c2aa691ce24eafe3dc6f9a54c18655","head":{"label":"Tommytrg:fix-5055","ref":"fix-5055","sha":"5fe6c70d36c2aa691ce24eafe3dc6f9a54c18655","user":{"login":"Tommytrg","id":24905681,"node_id":"MDQ6VXNlcjI0OTA1Njgx","avatar_url":"https://avatars0.githubusercontent.com/u/24905681?v=4","gravatar_id":"","url":"https://api.github.com/users/Tommytrg","html_url":"https://github.com/Tommytrg","followers_url":"https://api.github.com/users/Tommytrg/followers","following_url":"https://api.github.com/users/Tommytrg/following{/other_user}","gists_url":"https://api.github.com/users/Tommytrg/gists{/gist_id}","starred_url":"https://api.github.com/users/Tommytrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tommytrg/subscriptions","organizations_url":"https://api.github.com/users/Tommytrg/orgs","repos_url":"https://api.github.com/users/Tommytrg/repos","events_url":"https://api.github.com/users/Tommytrg/events{/privacy}","received_events_url":"https://api.github.com/users/Tommytrg/received_events","type":"User","site_admin":false},"repo":{"id":158273238,"node_id":"MDEwOlJlcG9zaXRvcnkxNTgyNzMyMzg=","name":"flatbuffers","full_name":"Tommytrg/flatbuffers","private":false,"owner":{"login":"Tommytrg","id":24905681,"node_id":"MDQ6VXNlcjI0OTA1Njgx","avatar_url":"https://avatars0.githubusercontent.com/u/24905681?v=4","gravatar_id":"","url":"https://api.github.com/users/Tommytrg","html_url":"https://github.com/Tommytrg","followers_url":"https://api.github.com/users/Tommytrg/followers","following_url":"https://api.github.com/users/Tommytrg/following{/other_user}","gists_url":"https://api.github.com/users/Tommytrg/gists{/gist_id}","starred_url":"https://api.github.com/users/Tommytrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tommytrg/subscriptions","organizations_url":"https://api.github.com/users/Tommytrg/orgs","repos_url":"https://api.github.com/users/Tommytrg/repos","events_url":"https://api.github.com/users/Tommytrg/events{/privacy}","received_events_url":"https://api.github.com/users/Tommytrg/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Tommytrg/flatbuffers","description":"Memory Efficient Serialization Library","fork":true,"url":"https://api.github.com/repos/Tommytrg/flatbuffers","forks_url":"https://api.github.com/repos/Tommytrg/flatbuffers/forks","keys_url":"https://api.github.com/repos/Tommytrg/flatbuffers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tommytrg/flatbuffers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tommytrg/flatbuffers/teams","hooks_url":"https://api.github.com/repos/Tommytrg/flatbuffers/hooks","issue_events_url":"https://api.github.com/repos/Tommytrg/flatbuffers/issues/events{/number}","events_url":"https://api.github.com/repos/Tommytrg/flatbuffers/events","assignees_url":"https://api.github.com/repos/Tommytrg/flatbuffers/assignees{/user}","branches_url":"https://api.github.com/repos/Tommytrg/flatbuffers/branches{/branch}","tags_url":"https://api.github.com/repos/Tommytrg/flatbuffers/tags","blobs_url":"https://api.github.com/repos/Tommytrg/flatbuffers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tommytrg/flatbuffers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tommytrg/flatbuffers/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tommytrg/flatbuffers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tommytrg/flatbuffers/statuses/{sha}","languages_url":"https://api.github.com/repos/Tommytrg/flatbuffers/languages","stargazers_url":"https://api.github.com/repos/Tommytrg/flatbuffers/stargazers","contributors_url":"https://api.github.com/repos/Tommytrg/flatbuffers/contributors","subscribers_url":"https://api.github.com/repos/Tommytrg/flatbuffers/subscribers","subscription_url":"https://api.github.com/repos/Tommytrg/flatbuffers/subscription","commits_url":"https://api.github.com/repos/Tommytrg/flatbuffers/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tommytrg/flatbuffers/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tommytrg/flatbuffers/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tommytrg/flatbuffers/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tommytrg/flatbuffers/contents/{+path}","compare_url":"https://api.github.com/repos/Tommytrg/flatbuffers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tommytrg/flatbuffers/merges","archive_url":"https://api.github.com/repos/Tommytrg/flatbuffers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tommytrg/flatbuffers/downloads","issues_url":"https://api.github.com/repos/Tommytrg/flatbuffers/issues{/number}","pulls_url":"https://api.github.com/repos/Tommytrg/flatbuffers/pulls{/number}","milestones_url":"https://api.github.com/repos/Tommytrg/flatbuffers/milestones{/number}","notifications_url":"https://api.github.com/repos/Tommytrg/flatbuffers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tommytrg/flatbuffers/labels{/name}","releases_url":"https://api.github.com/repos/Tommytrg/flatbuffers/releases{/id}","deployments_url":"https://api.github.com/repos/Tommytrg/flatbuffers/deployments","created_at":"2018-11-19T18:39:44Z","updated_at":"2018-11-19T18:39:47Z","pushed_at":"2018-11-19T18:40:38Z","git_url":"git://github.com/Tommytrg/flatbuffers.git","ssh_url":"git@github.com:Tommytrg/flatbuffers.git","clone_url":"https://github.com/Tommytrg/flatbuffers.git","svn_url":"https://github.com/Tommytrg/flatbuffers","homepage":"http://google.github.io/flatbuffers/","size":7830,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"0143f4e3643bf496abda878b286db949d933e915","user":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":19953044,"node_id":"MDEwOlJlcG9zaXRvcnkxOTk1MzA0NA==","name":"flatbuffers","full_name":"google/flatbuffers","private":false,"owner":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/google/flatbuffers","description":"Memory Efficient Serialization Library","fork":false,"url":"https://api.github.com/repos/google/flatbuffers","forks_url":"https://api.github.com/repos/google/flatbuffers/forks","keys_url":"https://api.github.com/repos/google/flatbuffers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/flatbuffers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/flatbuffers/teams","hooks_url":"https://api.github.com/repos/google/flatbuffers/hooks","issue_events_url":"https://api.github.com/repos/google/flatbuffers/issues/events{/number}","events_url":"https://api.github.com/repos/google/flatbuffers/events","assignees_url":"https://api.github.com/repos/google/flatbuffers/assignees{/user}","branches_url":"https://api.github.com/repos/google/flatbuffers/branches{/branch}","tags_url":"https://api.github.com/repos/google/flatbuffers/tags","blobs_url":"https://api.github.com/repos/google/flatbuffers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/flatbuffers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/flatbuffers/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/flatbuffers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/flatbuffers/statuses/{sha}","languages_url":"https://api.github.com/repos/google/flatbuffers/languages","stargazers_url":"https://api.github.com/repos/google/flatbuffers/stargazers","contributors_url":"https://api.github.com/repos/google/flatbuffers/contributors","subscribers_url":"https://api.github.com/repos/google/flatbuffers/subscribers","subscription_url":"https://api.github.com/repos/google/flatbuffers/subscription","commits_url":"https://api.github.com/repos/google/flatbuffers/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/flatbuffers/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/flatbuffers/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/flatbuffers/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/flatbuffers/contents/{+path}","compare_url":"https://api.github.com/repos/google/flatbuffers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/flatbuffers/merges","archive_url":"https://api.github.com/repos/google/flatbuffers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/flatbuffers/downloads","issues_url":"https://api.github.com/repos/google/flatbuffers/issues{/number}","pulls_url":"https://api.github.com/repos/google/flatbuffers/pulls{/number}","milestones_url":"https://api.github.com/repos/google/flatbuffers/milestones{/number}","notifications_url":"https://api.github.com/repos/google/flatbuffers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/flatbuffers/labels{/name}","releases_url":"https://api.github.com/repos/google/flatbuffers/releases{/id}","deployments_url":"https://api.github.com/repos/google/flatbuffers/deployments","created_at":"2014-05-19T18:33:01Z","updated_at":"2018-11-19T17:35:48Z","pushed_at":"2018-11-19T23:18:22Z","git_url":"git://github.com/google/flatbuffers.git","ssh_url":"git@github.com:google/flatbuffers.git","clone_url":"https://github.com/google/flatbuffers.git","svn_url":"https://github.com/google/flatbuffers","homepage":"http://google.github.io/flatbuffers/","size":7867,"stargazers_count":10756,"watchers_count":10756,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1702,"mirror_url":null,"archived":false,"open_issues_count":322,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1702,"open_issues":322,"watchers":10756,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/flatbuffers/pulls/5056"},"html":{"href":"https://github.com/google/flatbuffers/pull/5056"},"issue":{"href":"https://api.github.com/repos/google/flatbuffers/issues/5056"},"comments":{"href":"https://api.github.com/repos/google/flatbuffers/issues/5056/comments"},"review_comments":{"href":"https://api.github.com/repos/google/flatbuffers/pulls/5056/comments"},"review_comment":{"href":"https://api.github.com/repos/google/flatbuffers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/flatbuffers/pulls/5056/commits"},"statuses":{"href":"https://api.github.com/repos/google/flatbuffers/statuses/5fe6c70d36c2aa691ce24eafe3dc6f9a54c18655"}},"author_association":"NONE"}}
{"actor":{"display_login":"rw"}}