Merge pull request #512 from dtolnay/128key

Quotes around u128 in map key
diff --git a/src/ser.rs b/src/ser.rs
index d0fc66a..463c15a 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -987,10 +987,22 @@
 
     serde_if_integer128! {
         fn serialize_i128(self, value: i128) -> Result<()> {
-            self.ser
+            try!(self
+                .ser
+                .formatter
+                .begin_string(&mut self.ser.writer)
+                .map_err(Error::io));
+            try!(self
+                .ser
                 .formatter
                 .write_number_str(&mut self.ser.writer, &value.to_string())
-                .map_err(Error::io)
+                .map_err(Error::io));
+            try!(self
+                .ser
+                .formatter
+                .end_string(&mut self.ser.writer)
+                .map_err(Error::io));
+            Ok(())
         }
     }
 
@@ -1072,10 +1084,22 @@
 
     serde_if_integer128! {
         fn serialize_u128(self, value: u128) -> Result<()> {
-            self.ser
+            try!(self
+                .ser
+                .formatter
+                .begin_string(&mut self.ser.writer)
+                .map_err(Error::io));
+            try!(self
+                .ser
                 .formatter
                 .write_number_str(&mut self.ser.writer, &value.to_string())
-                .map_err(Error::io)
+                .map_err(Error::io));
+            try!(self
+                .ser
+                .formatter
+                .end_string(&mut self.ser.writer)
+                .map_err(Error::io));
+            Ok(())
         }
     }
 
diff --git a/tests/test.rs b/tests/test.rs
index 46b3396..548f71a 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1783,6 +1783,16 @@
 }
 
 #[test]
+fn test_integer128_key() {
+    let map = treemap! {
+        100000000000000000000000000000000000000u128 => ()
+    };
+    let j = r#"{"100000000000000000000000000000000000000":null}"#;
+    assert_eq!(to_string(&map).unwrap(), j);
+    assert_eq!(from_str::<BTreeMap<u128, ()>>(j).unwrap(), map);
+}
+
+#[test]
 fn test_deny_float_key() {
     #[derive(Eq, PartialEq, Ord, PartialOrd)]
     struct Float;