{"action":"created","comment":{"url":"https://api.github.com/repos/serde-rs/json/pulls/comments/174662469","pull_request_review_id":104059305,"id":174662469,"diff_hunk":"@@ -348,72 +371,441 @@ impl serde::ser::SerializeMap for SerializeMap {\n     where\n         T: Serialize,\n     {\n-        match try!(to_value(&key)) {\n-            Value::String(s) => self.next_key = Some(s),\n-            Value::Number(n) => {\n-                if n.is_u64() || n.is_i64() {\n-                    self.next_key = Some(n.to_string())\n-                } else {\n-                    return Err(Error::syntax(ErrorCode::KeyMustBeAString, 0, 0));\n-                }\n-            }\n-            _ => return Err(Error::syntax(ErrorCode::KeyMustBeAString, 0, 0)),\n-        };\n-        Ok(())\n+        match *self {\n+            SerializeMap::Map { ref mut next_key, .. } => {\n+                *next_key = Some(try!(key.serialize(MapKeySerializer)));\n+                Ok(())\n+            },\n+            #[cfg(feature = \"arbitrary_precision\")]\n+            SerializeMap::Number { .. } => unreachable!(),\n+        }\n     }\n \n     fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>\n     where\n         T: Serialize,\n     {\n-        let key = self.next_key.take();\n-        // Panic because this indicates a bug in the program rather than an\n-        // expected failure.\n-        let key = key.expect(\"serialize_value called before serialize_key\");\n-        self.map.insert(key, try!(to_value(&value)));\n-        Ok(())\n+        match *self {\n+            SerializeMap::Map { ref mut map, ref mut next_key } => {\n+                let key = next_key.take();\n+                // Panic because this indicates a bug in the program rather than an\n+                // expected failure.\n+                let key = key.expect(\"serialize_value called before serialize_key\");\n+                map.insert(key, try!(to_value(&value)));\n+                Ok(())\n+            },\n+            #[cfg(feature = \"arbitrary_precision\")]\n+            SerializeMap::Number { .. } => unreachable!(),\n+        }\n     }\n \n     fn end(self) -> Result<Value, Error> {\n-        Ok(Value::Object(self.map))\n+        match self {\n+            SerializeMap::Map { map, .. } => Ok(Value::Object(map)),\n+            #[cfg(feature = \"arbitrary_precision\")]\n+            SerializeMap::Number { .. } => unreachable!(),\n+        }\n+    }\n+}\n+\n+struct MapKeySerializer;\n+\n+fn key_must_be_a_string() -> Error {\n+    Error::syntax(ErrorCode::KeyMustBeAString, 0, 0)\n+}\n+\n+impl serde::Serializer for MapKeySerializer {\n+    type Ok = String;\n+    type Error = Error;\n+\n+    type SerializeSeq = Impossible<String, Error>;\n+    type SerializeTuple = Impossible<String, Error>;\n+    type SerializeTupleStruct = Impossible<String, Error>;\n+    type SerializeTupleVariant = Impossible<String, Error>;\n+    type SerializeMap = Impossible<String, Error>;\n+    type SerializeStruct = Impossible<String, Error>;\n+    type SerializeStructVariant = Impossible<String, Error>;\n+\n+    #[inline]\n+    fn serialize_str(self, value: &str) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_owned())\n+    }\n+\n+    #[inline]\n+    fn serialize_unit_variant(\n+        self,\n+        _name: &'static str,\n+        _variant_index: u32,\n+        variant: &'static str\n+    ) -> Result<Self::Ok, Self::Error> {\n+        Ok(variant.to_owned())\n+    }\n+\n+    #[inline]\n+    fn serialize_newtype_struct<T: ?Sized>(\n+        self,\n+        _name: &'static str,\n+        value: &T\n+    ) -> Result<Self::Ok, Self::Error>\n+        where T: Serialize,\n+    {\n+        value.serialize(self)\n+    }\n+\n+    fn serialize_bool(self, _value: bool) -> Result<Self::Ok, Self::Error> {\n+        Err(key_must_be_a_string())\n+    }\n+\n+    fn serialize_i8(self, value: i8) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_i16(self, value: i16) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_i32(self, value: i32) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_i64(self, value: i64) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_u8(self, value: u8) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_u16(self, value: u16) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_u32(self, value: u32) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_u64(self, value: u64) -> Result<Self::Ok, Self::Error> {\n+        Ok(value.to_string())\n+    }\n+\n+    fn serialize_f32(self, _value: f32) -> Result<Self::Ok, Self::Error> {\n+        Err(key_must_be_a_string())\n+    }\n+\n+    fn serialize_f64(self, _value: f64) -> Result<Self::Ok, Self::Error> {\n+        Err(key_must_be_a_string())\n+    }\n+\n+    fn serialize_char(self, _value: char) -> Result<Self::Ok, Self::Error> {\n+        Err(key_must_be_a_string())","path":"src/value/ser.rs","position":239,"original_position":239,"commit_id":"50aedf098f98e065fd0b0d6ac811f51f5d70fd1b","original_commit_id":"50aedf098f98e065fd0b0d6ac811f51f5d70fd1b","user":{"login":"alexreg","id":67036,"avatar_url":"https://avatars3.githubusercontent.com/u/67036?v=4","gravatar_id":"","url":"https://api.github.com/users/alexreg","html_url":"https://github.com/alexreg","followers_url":"https://api.github.com/users/alexreg/followers","following_url":"https://api.github.com/users/alexreg/following{/other_user}","gists_url":"https://api.github.com/users/alexreg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexreg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexreg/subscriptions","organizations_url":"https://api.github.com/users/alexreg/orgs","repos_url":"https://api.github.com/users/alexreg/repos","events_url":"https://api.github.com/users/alexreg/events{/privacy}","received_events_url":"https://api.github.com/users/alexreg/received_events","type":"User","site_admin":false},"body":"Good catch. Fixed now.","created_at":"2018-03-15T02:29:48Z","updated_at":"2018-03-15T02:29:48Z","html_url":"https://github.com/serde-rs/json/pull/416#discussion_r174662469","pull_request_url":"https://api.github.com/repos/serde-rs/json/pulls/416","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/serde-rs/json/pulls/comments/174662469"},"html":{"href":"https://github.com/serde-rs/json/pull/416#discussion_r174662469"},"pull_request":{"href":"https://api.github.com/repos/serde-rs/json/pulls/416"}},"in_reply_to_id":174237384},"pull_request":{"url":"https://api.github.com/repos/serde-rs/json/pulls/416","id":172418878,"html_url":"https://github.com/serde-rs/json/pull/416","diff_url":"https://github.com/serde-rs/json/pull/416.diff","patch_url":"https://github.com/serde-rs/json/pull/416.patch","issue_url":"https://api.github.com/repos/serde-rs/json/issues/416","number":416,"state":"open","locked":false,"title":"Arbitrary-precision numerics support","user":{"login":"alexreg","id":67036,"avatar_url":"https://avatars3.githubusercontent.com/u/67036?v=4","gravatar_id":"","url":"https://api.github.com/users/alexreg","html_url":"https://github.com/alexreg","followers_url":"https://api.github.com/users/alexreg/followers","following_url":"https://api.github.com/users/alexreg/following{/other_user}","gists_url":"https://api.github.com/users/alexreg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexreg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexreg/subscriptions","organizations_url":"https://api.github.com/users/alexreg/orgs","repos_url":"https://api.github.com/users/alexreg/repos","events_url":"https://api.github.com/users/alexreg/events{/privacy}","received_events_url":"https://api.github.com/users/alexreg/received_events","type":"User","site_admin":false},"body":"Added support for arbitrary-precision numerics, in a similar way that the *toml* crate does for date-times (using an internal special struct).","created_at":"2018-03-02T04:16:11Z","updated_at":"2018-03-15T02:29:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1424217554496b9a7a342c79faa9fc461580bd41","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/serde-rs/json/pulls/416/commits","review_comments_url":"https://api.github.com/repos/serde-rs/json/pulls/416/comments","review_comment_url":"https://api.github.com/repos/serde-rs/json/pulls/comments{/number}","comments_url":"https://api.github.com/repos/serde-rs/json/issues/416/comments","statuses_url":"https://api.github.com/repos/serde-rs/json/statuses/50aedf098f98e065fd0b0d6ac811f51f5d70fd1b","head":{"label":"alexreg:arbitrary-precision","ref":"arbitrary-precision","sha":"50aedf098f98e065fd0b0d6ac811f51f5d70fd1b","user":{"login":"alexreg","id":67036,"avatar_url":"https://avatars3.githubusercontent.com/u/67036?v=4","gravatar_id":"","url":"https://api.github.com/users/alexreg","html_url":"https://github.com/alexreg","followers_url":"https://api.github.com/users/alexreg/followers","following_url":"https://api.github.com/users/alexreg/following{/other_user}","gists_url":"https://api.github.com/users/alexreg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexreg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexreg/subscriptions","organizations_url":"https://api.github.com/users/alexreg/orgs","repos_url":"https://api.github.com/users/alexreg/repos","events_url":"https://api.github.com/users/alexreg/events{/privacy}","received_events_url":"https://api.github.com/users/alexreg/received_events","type":"User","site_admin":false},"repo":{"id":101081070,"name":"serde-json","full_name":"alexreg/serde-json","owner":{"login":"alexreg","id":67036,"avatar_url":"https://avatars3.githubusercontent.com/u/67036?v=4","gravatar_id":"","url":"https://api.github.com/users/alexreg","html_url":"https://github.com/alexreg","followers_url":"https://api.github.com/users/alexreg/followers","following_url":"https://api.github.com/users/alexreg/following{/other_user}","gists_url":"https://api.github.com/users/alexreg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexreg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexreg/subscriptions","organizations_url":"https://api.github.com/users/alexreg/orgs","repos_url":"https://api.github.com/users/alexreg/repos","events_url":"https://api.github.com/users/alexreg/events{/privacy}","received_events_url":"https://api.github.com/users/alexreg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexreg/serde-json","description":"JSON Serialization for Rust","fork":true,"url":"https://api.github.com/repos/alexreg/serde-json","forks_url":"https://api.github.com/repos/alexreg/serde-json/forks","keys_url":"https://api.github.com/repos/alexreg/serde-json/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexreg/serde-json/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexreg/serde-json/teams","hooks_url":"https://api.github.com/repos/alexreg/serde-json/hooks","issue_events_url":"https://api.github.com/repos/alexreg/serde-json/issues/events{/number}","events_url":"https://api.github.com/repos/alexreg/serde-json/events","assignees_url":"https://api.github.com/repos/alexreg/serde-json/assignees{/user}","branches_url":"https://api.github.com/repos/alexreg/serde-json/branches{/branch}","tags_url":"https://api.github.com/repos/alexreg/serde-json/tags","blobs_url":"https://api.github.com/repos/alexreg/serde-json/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexreg/serde-json/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexreg/serde-json/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexreg/serde-json/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexreg/serde-json/statuses/{sha}","languages_url":"https://api.github.com/repos/alexreg/serde-json/languages","stargazers_url":"https://api.github.com/repos/alexreg/serde-json/stargazers","contributors_url":"https://api.github.com/repos/alexreg/serde-json/contributors","subscribers_url":"https://api.github.com/repos/alexreg/serde-json/subscribers","subscription_url":"https://api.github.com/repos/alexreg/serde-json/subscription","commits_url":"https://api.github.com/repos/alexreg/serde-json/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexreg/serde-json/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexreg/serde-json/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexreg/serde-json/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexreg/serde-json/contents/{+path}","compare_url":"https://api.github.com/repos/alexreg/serde-json/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexreg/serde-json/merges","archive_url":"https://api.github.com/repos/alexreg/serde-json/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexreg/serde-json/downloads","issues_url":"https://api.github.com/repos/alexreg/serde-json/issues{/number}","pulls_url":"https://api.github.com/repos/alexreg/serde-json/pulls{/number}","milestones_url":"https://api.github.com/repos/alexreg/serde-json/milestones{/number}","notifications_url":"https://api.github.com/repos/alexreg/serde-json/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexreg/serde-json/labels{/name}","releases_url":"https://api.github.com/repos/alexreg/serde-json/releases{/id}","deployments_url":"https://api.github.com/repos/alexreg/serde-json/deployments","created_at":"2017-08-22T15:55:08Z","updated_at":"2017-08-22T15:56:09Z","pushed_at":"2018-03-12T01:49:45Z","git_url":"git://github.com/alexreg/serde-json.git","ssh_url":"git@github.com:alexreg/serde-json.git","clone_url":"https://github.com/alexreg/serde-json.git","svn_url":"https://github.com/alexreg/serde-json","homepage":"http://docs.serde.rs/serde_json/","size":1137,"stargazers_count":1,"watchers_count":1,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"serde-rs:master","ref":"master","sha":"aa63c9302da2127390663e2f781359adde76ef7a","user":{"login":"serde-rs","id":11965399,"avatar_url":"https://avatars3.githubusercontent.com/u/11965399?v=4","gravatar_id":"","url":"https://api.github.com/users/serde-rs","html_url":"https://github.com/serde-rs","followers_url":"https://api.github.com/users/serde-rs/followers","following_url":"https://api.github.com/users/serde-rs/following{/other_user}","gists_url":"https://api.github.com/users/serde-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/serde-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serde-rs/subscriptions","organizations_url":"https://api.github.com/users/serde-rs/orgs","repos_url":"https://api.github.com/users/serde-rs/repos","events_url":"https://api.github.com/users/serde-rs/events{/privacy}","received_events_url":"https://api.github.com/users/serde-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":35894511,"name":"json","full_name":"serde-rs/json","owner":{"login":"serde-rs","id":11965399,"avatar_url":"https://avatars3.githubusercontent.com/u/11965399?v=4","gravatar_id":"","url":"https://api.github.com/users/serde-rs","html_url":"https://github.com/serde-rs","followers_url":"https://api.github.com/users/serde-rs/followers","following_url":"https://api.github.com/users/serde-rs/following{/other_user}","gists_url":"https://api.github.com/users/serde-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/serde-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serde-rs/subscriptions","organizations_url":"https://api.github.com/users/serde-rs/orgs","repos_url":"https://api.github.com/users/serde-rs/repos","events_url":"https://api.github.com/users/serde-rs/events{/privacy}","received_events_url":"https://api.github.com/users/serde-rs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/serde-rs/json","description":"Strongly typed JSON library for Rust","fork":false,"url":"https://api.github.com/repos/serde-rs/json","forks_url":"https://api.github.com/repos/serde-rs/json/forks","keys_url":"https://api.github.com/repos/serde-rs/json/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serde-rs/json/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serde-rs/json/teams","hooks_url":"https://api.github.com/repos/serde-rs/json/hooks","issue_events_url":"https://api.github.com/repos/serde-rs/json/issues/events{/number}","events_url":"https://api.github.com/repos/serde-rs/json/events","assignees_url":"https://api.github.com/repos/serde-rs/json/assignees{/user}","branches_url":"https://api.github.com/repos/serde-rs/json/branches{/branch}","tags_url":"https://api.github.com/repos/serde-rs/json/tags","blobs_url":"https://api.github.com/repos/serde-rs/json/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serde-rs/json/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serde-rs/json/git/refs{/sha}","trees_url":"https://api.github.com/repos/serde-rs/json/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serde-rs/json/statuses/{sha}","languages_url":"https://api.github.com/repos/serde-rs/json/languages","stargazers_url":"https://api.github.com/repos/serde-rs/json/stargazers","contributors_url":"https://api.github.com/repos/serde-rs/json/contributors","subscribers_url":"https://api.github.com/repos/serde-rs/json/subscribers","subscription_url":"https://api.github.com/repos/serde-rs/json/subscription","commits_url":"https://api.github.com/repos/serde-rs/json/commits{/sha}","git_commits_url":"https://api.github.com/repos/serde-rs/json/git/commits{/sha}","comments_url":"https://api.github.com/repos/serde-rs/json/comments{/number}","issue_comment_url":"https://api.github.com/repos/serde-rs/json/issues/comments{/number}","contents_url":"https://api.github.com/repos/serde-rs/json/contents/{+path}","compare_url":"https://api.github.com/repos/serde-rs/json/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serde-rs/json/merges","archive_url":"https://api.github.com/repos/serde-rs/json/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serde-rs/json/downloads","issues_url":"https://api.github.com/repos/serde-rs/json/issues{/number}","pulls_url":"https://api.github.com/repos/serde-rs/json/pulls{/number}","milestones_url":"https://api.github.com/repos/serde-rs/json/milestones{/number}","notifications_url":"https://api.github.com/repos/serde-rs/json/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serde-rs/json/labels{/name}","releases_url":"https://api.github.com/repos/serde-rs/json/releases{/id}","deployments_url":"https://api.github.com/repos/serde-rs/json/deployments","created_at":"2015-05-19T16:30:20Z","updated_at":"2018-03-14T20:55:57Z","pushed_at":"2018-03-12T01:49:46Z","git_url":"git://github.com/serde-rs/json.git","ssh_url":"git@github.com:serde-rs/json.git","clone_url":"https://github.com/serde-rs/json.git","svn_url":"https://github.com/serde-rs/json","homepage":"http://docs.serde.rs/serde_json/","size":1108,"stargazers_count":434,"watchers_count":434,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":111,"mirror_url":null,"archived":false,"open_issues_count":51,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":111,"open_issues":51,"watchers":434,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/serde-rs/json/pulls/416"},"html":{"href":"https://github.com/serde-rs/json/pull/416"},"issue":{"href":"https://api.github.com/repos/serde-rs/json/issues/416"},"comments":{"href":"https://api.github.com/repos/serde-rs/json/issues/416/comments"},"review_comments":{"href":"https://api.github.com/repos/serde-rs/json/pulls/416/comments"},"review_comment":{"href":"https://api.github.com/repos/serde-rs/json/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/serde-rs/json/pulls/416/commits"},"statuses":{"href":"https://api.github.com/repos/serde-rs/json/statuses/50aedf098f98e065fd0b0d6ac811f51f5d70fd1b"}},"author_association":"NONE"}}
{"actor":{"display_login":"alexreg"}}