// The Serde data model allows map keys to be any serializable type. JSON
// only allows string keys so the implementation below will produce invalid
// JSON if the key serializes as something other than a string.
//
// A real JSON serializer would need to validate that map keys are strings.
// This can be done by using a different Serializer to serialize the key
// (instead of `&mut **self`) and having that other serializer only
// implement `serialize_str` and return an error on any other data type.
The Serde data model allows map keys to be any serializable type. JSON
only allows string keys so the implementation below will produce invalid
JSON if the key serializes as something other than a string.

A real JSON serializer would need to validate that map keys are strings.
This can be done by using a different Serializer to serialize the key
(instead of `&mut **self`) and having that other serializer only
implement `serialize_str` and return an error on any other data type.
The Serde data model allows map keys to be any serializable type . JSON only allows string keys so the implementation below will produce invalid JSON if the key serializes as something other than a string . A real JSON serializer would need to validate that map keys are strings . This can be done by using a different Serializer to serialize the key ( instead of ` &mut ** self ` ) and having that other serializer only implement ` serialize_str ` and return an error on any other data type .
fn serialize_key<T>(&mut self, key: &T) -> Result<()>
    where
        T: ?Sized + Serialize,
    {
        self.current_key = Some(new_ruby_object(key)?);
        Ok(())
    }
fn serialize_key < T > ( & mut self , key : & T ) -> Result < ( ) > where T : ? Sized + Serialize , { self . current_key = Some ( new_ruby_object ( key ) ? ) ; Ok ( ( ) ) }
The Serde data model allows map keys to be any serializable type.
The Serde data model allows map keys to be any serializable type .
&mut self
key
&T