{"action":"created","comment":{"url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/comments/33961733","id":33961733,"diff_hunk":"@@ -8,11 +8,35 @@ use rustc_serialize::json::{Json, ToJson};\n /// An Optional value can contain Optional::Some<T> or Optional::Absent.\n /// It is similar to an Option, but Optional::Absent means it will be\n /// omitted when serialized.\n+#[derive(Debug, Copy, Clone)]\n pub enum Optional<T> {\n     Value(T),\n     Absent,\n }\n \n+impl<T> Optional<T> {\n+    pub fn map_or<U, F: FnOnce(T) -> U>(self, def: U, f: F) -> U {\n+        match self {\n+            Optional::Value(v) => f(v),\n+            Optional::Absent => def,\n+        }\n+    }","path":"spaceapi/src/lib.rs","position":16,"original_position":16,"commit_id":"90a06d6daeac24db9a0e85c0ef551ac5ce349395","original_commit_id":"90a06d6daeac24db9a0e85c0ef551ac5ce349395","user":{"login":"rnestler","id":1435346,"avatar_url":"https://avatars.githubusercontent.com/u/1435346?v=3","gravatar_id":"","url":"https://api.github.com/users/rnestler","html_url":"https://github.com/rnestler","followers_url":"https://api.github.com/users/rnestler/followers","following_url":"https://api.github.com/users/rnestler/following{/other_user}","gists_url":"https://api.github.com/users/rnestler/gists{/gist_id}","starred_url":"https://api.github.com/users/rnestler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnestler/subscriptions","organizations_url":"https://api.github.com/users/rnestler/orgs","repos_url":"https://api.github.com/users/rnestler/repos","events_url":"https://api.github.com/users/rnestler/events{/privacy}","received_events_url":"https://api.github.com/users/rnestler/received_events","type":"User","site_admin":false},"body":"Also the difference in JSON between ``null`` and absent is not clear at all:\r\nhttp://stackoverflow.com/questions/15686995/should-null-values-be-included-in-json-responses-from-a-rest-api\r\nhttps://groups.google.com/forum/?fromgroups=#!topic/api-craft/MrEixUwOCWA","created_at":"2015-07-06T17:49:37Z","updated_at":"2015-07-06T17:49:37Z","html_url":"https://github.com/coredump-ch/spaceapi/pull/34#discussion_r33961733","pull_request_url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/comments/33961733"},"html":{"href":"https://github.com/coredump-ch/spaceapi/pull/34#discussion_r33961733"},"pull_request":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34","id":39226485,"html_url":"https://github.com/coredump-ch/spaceapi/pull/34","diff_url":"https://github.com/coredump-ch/spaceapi/pull/34.diff","patch_url":"https://github.com/coredump-ch/spaceapi/pull/34.patch","issue_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues/34","number":34,"state":"open","locked":false,"title":"Rnestler/cleanup spaceapi","user":{"login":"rnestler","id":1435346,"avatar_url":"https://avatars.githubusercontent.com/u/1435346?v=3","gravatar_id":"","url":"https://api.github.com/users/rnestler","html_url":"https://github.com/rnestler","followers_url":"https://api.github.com/users/rnestler/followers","following_url":"https://api.github.com/users/rnestler/following{/other_user}","gists_url":"https://api.github.com/users/rnestler/gists{/gist_id}","starred_url":"https://api.github.com/users/rnestler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnestler/subscriptions","organizations_url":"https://api.github.com/users/rnestler/orgs","repos_url":"https://api.github.com/users/rnestler/repos","events_url":"https://api.github.com/users/rnestler/events{/privacy}","received_events_url":"https://api.github.com/users/rnestler/received_events","type":"User","site_admin":false},"body":"This lets us remove all the noisy match statements and replaces them by calls to map_or(). I did most of the conversion using a vim macro, but the unit-tests are passing so it should be fine :smiley: \r\n@dbrgn @schmijos Please review","created_at":"2015-07-05T20:31:42Z","updated_at":"2015-07-06T17:49:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d1ea1019c91dd03bd690eb7c103d3c01c7dbbf36","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34/commits","review_comments_url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34/comments","review_comment_url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues/34/comments","statuses_url":"https://api.github.com/repos/coredump-ch/spaceapi/statuses/90a06d6daeac24db9a0e85c0ef551ac5ce349395","head":{"label":"coredump-ch:rnestler/cleanup_spaceapi","ref":"rnestler/cleanup_spaceapi","sha":"90a06d6daeac24db9a0e85c0ef551ac5ce349395","user":{"login":"coredump-ch","id":5295118,"avatar_url":"https://avatars.githubusercontent.com/u/5295118?v=3","gravatar_id":"","url":"https://api.github.com/users/coredump-ch","html_url":"https://github.com/coredump-ch","followers_url":"https://api.github.com/users/coredump-ch/followers","following_url":"https://api.github.com/users/coredump-ch/following{/other_user}","gists_url":"https://api.github.com/users/coredump-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/coredump-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coredump-ch/subscriptions","organizations_url":"https://api.github.com/users/coredump-ch/orgs","repos_url":"https://api.github.com/users/coredump-ch/repos","events_url":"https://api.github.com/users/coredump-ch/events{/privacy}","received_events_url":"https://api.github.com/users/coredump-ch/received_events","type":"Organization","site_admin":false},"repo":{"id":16317444,"name":"spaceapi","full_name":"coredump-ch/spaceapi","owner":{"login":"coredump-ch","id":5295118,"avatar_url":"https://avatars.githubusercontent.com/u/5295118?v=3","gravatar_id":"","url":"https://api.github.com/users/coredump-ch","html_url":"https://github.com/coredump-ch","followers_url":"https://api.github.com/users/coredump-ch/followers","following_url":"https://api.github.com/users/coredump-ch/following{/other_user}","gists_url":"https://api.github.com/users/coredump-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/coredump-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coredump-ch/subscriptions","organizations_url":"https://api.github.com/users/coredump-ch/orgs","repos_url":"https://api.github.com/users/coredump-ch/repos","events_url":"https://api.github.com/users/coredump-ch/events{/privacy}","received_events_url":"https://api.github.com/users/coredump-ch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coredump-ch/spaceapi","description":"Implementation of the Space API.","fork":false,"url":"https://api.github.com/repos/coredump-ch/spaceapi","forks_url":"https://api.github.com/repos/coredump-ch/spaceapi/forks","keys_url":"https://api.github.com/repos/coredump-ch/spaceapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coredump-ch/spaceapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coredump-ch/spaceapi/teams","hooks_url":"https://api.github.com/repos/coredump-ch/spaceapi/hooks","issue_events_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues/events{/number}","events_url":"https://api.github.com/repos/coredump-ch/spaceapi/events","assignees_url":"https://api.github.com/repos/coredump-ch/spaceapi/assignees{/user}","branches_url":"https://api.github.com/repos/coredump-ch/spaceapi/branches{/branch}","tags_url":"https://api.github.com/repos/coredump-ch/spaceapi/tags","blobs_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coredump-ch/spaceapi/statuses/{sha}","languages_url":"https://api.github.com/repos/coredump-ch/spaceapi/languages","stargazers_url":"https://api.github.com/repos/coredump-ch/spaceapi/stargazers","contributors_url":"https://api.github.com/repos/coredump-ch/spaceapi/contributors","subscribers_url":"https://api.github.com/repos/coredump-ch/spaceapi/subscribers","subscription_url":"https://api.github.com/repos/coredump-ch/spaceapi/subscription","commits_url":"https://api.github.com/repos/coredump-ch/spaceapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/coredump-ch/spaceapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/coredump-ch/spaceapi/contents/{+path}","compare_url":"https://api.github.com/repos/coredump-ch/spaceapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coredump-ch/spaceapi/merges","archive_url":"https://api.github.com/repos/coredump-ch/spaceapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coredump-ch/spaceapi/downloads","issues_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues{/number}","pulls_url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls{/number}","milestones_url":"https://api.github.com/repos/coredump-ch/spaceapi/milestones{/number}","notifications_url":"https://api.github.com/repos/coredump-ch/spaceapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coredump-ch/spaceapi/labels{/name}","releases_url":"https://api.github.com/repos/coredump-ch/spaceapi/releases{/id}","created_at":"2014-01-28T16:23:32Z","updated_at":"2015-06-03T06:45:20Z","pushed_at":"2015-07-05T20:31:42Z","git_url":"git://github.com/coredump-ch/spaceapi.git","ssh_url":"git@github.com:coredump-ch/spaceapi.git","clone_url":"https://github.com/coredump-ch/spaceapi.git","svn_url":"https://github.com/coredump-ch/spaceapi","homepage":null,"size":512,"stargazers_count":3,"watchers_count":3,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":3,"default_branch":"rust"}},"base":{"label":"coredump-ch:rust","ref":"rust","sha":"703ba138635a7ad561e2f0a0039060fd2224e059","user":{"login":"coredump-ch","id":5295118,"avatar_url":"https://avatars.githubusercontent.com/u/5295118?v=3","gravatar_id":"","url":"https://api.github.com/users/coredump-ch","html_url":"https://github.com/coredump-ch","followers_url":"https://api.github.com/users/coredump-ch/followers","following_url":"https://api.github.com/users/coredump-ch/following{/other_user}","gists_url":"https://api.github.com/users/coredump-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/coredump-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coredump-ch/subscriptions","organizations_url":"https://api.github.com/users/coredump-ch/orgs","repos_url":"https://api.github.com/users/coredump-ch/repos","events_url":"https://api.github.com/users/coredump-ch/events{/privacy}","received_events_url":"https://api.github.com/users/coredump-ch/received_events","type":"Organization","site_admin":false},"repo":{"id":16317444,"name":"spaceapi","full_name":"coredump-ch/spaceapi","owner":{"login":"coredump-ch","id":5295118,"avatar_url":"https://avatars.githubusercontent.com/u/5295118?v=3","gravatar_id":"","url":"https://api.github.com/users/coredump-ch","html_url":"https://github.com/coredump-ch","followers_url":"https://api.github.com/users/coredump-ch/followers","following_url":"https://api.github.com/users/coredump-ch/following{/other_user}","gists_url":"https://api.github.com/users/coredump-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/coredump-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coredump-ch/subscriptions","organizations_url":"https://api.github.com/users/coredump-ch/orgs","repos_url":"https://api.github.com/users/coredump-ch/repos","events_url":"https://api.github.com/users/coredump-ch/events{/privacy}","received_events_url":"https://api.github.com/users/coredump-ch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coredump-ch/spaceapi","description":"Implementation of the Space API.","fork":false,"url":"https://api.github.com/repos/coredump-ch/spaceapi","forks_url":"https://api.github.com/repos/coredump-ch/spaceapi/forks","keys_url":"https://api.github.com/repos/coredump-ch/spaceapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coredump-ch/spaceapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coredump-ch/spaceapi/teams","hooks_url":"https://api.github.com/repos/coredump-ch/spaceapi/hooks","issue_events_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues/events{/number}","events_url":"https://api.github.com/repos/coredump-ch/spaceapi/events","assignees_url":"https://api.github.com/repos/coredump-ch/spaceapi/assignees{/user}","branches_url":"https://api.github.com/repos/coredump-ch/spaceapi/branches{/branch}","tags_url":"https://api.github.com/repos/coredump-ch/spaceapi/tags","blobs_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coredump-ch/spaceapi/statuses/{sha}","languages_url":"https://api.github.com/repos/coredump-ch/spaceapi/languages","stargazers_url":"https://api.github.com/repos/coredump-ch/spaceapi/stargazers","contributors_url":"https://api.github.com/repos/coredump-ch/spaceapi/contributors","subscribers_url":"https://api.github.com/repos/coredump-ch/spaceapi/subscribers","subscription_url":"https://api.github.com/repos/coredump-ch/spaceapi/subscription","commits_url":"https://api.github.com/repos/coredump-ch/spaceapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/coredump-ch/spaceapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/coredump-ch/spaceapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/coredump-ch/spaceapi/contents/{+path}","compare_url":"https://api.github.com/repos/coredump-ch/spaceapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coredump-ch/spaceapi/merges","archive_url":"https://api.github.com/repos/coredump-ch/spaceapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coredump-ch/spaceapi/downloads","issues_url":"https://api.github.com/repos/coredump-ch/spaceapi/issues{/number}","pulls_url":"https://api.github.com/repos/coredump-ch/spaceapi/pulls{/number}","milestones_url":"https://api.github.com/repos/coredump-ch/spaceapi/milestones{/number}","notifications_url":"https://api.github.com/repos/coredump-ch/spaceapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coredump-ch/spaceapi/labels{/name}","releases_url":"https://api.github.com/repos/coredump-ch/spaceapi/releases{/id}","created_at":"2014-01-28T16:23:32Z","updated_at":"2015-06-03T06:45:20Z","pushed_at":"2015-07-05T20:31:42Z","git_url":"git://github.com/coredump-ch/spaceapi.git","ssh_url":"git@github.com:coredump-ch/spaceapi.git","clone_url":"https://github.com/coredump-ch/spaceapi.git","svn_url":"https://github.com/coredump-ch/spaceapi","homepage":null,"size":512,"stargazers_count":3,"watchers_count":3,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":3,"default_branch":"rust"}},"_links":{"self":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34"},"html":{"href":"https://github.com/coredump-ch/spaceapi/pull/34"},"issue":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/issues/34"},"comments":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/coredump-ch/spaceapi/statuses/90a06d6daeac24db9a0e85c0ef551ac5ce349395"}}}}