mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-09 20:11:01 +00:00
Allow the json::builder::ObjectBuilder to insert &str keys
This commit is contained in:
+2
-2
@@ -56,9 +56,9 @@ impl ObjectBuilder {
|
|||||||
Object(self.object)
|
Object(self.object)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert<T: ToJson>(self, key: String, value: T) -> ObjectBuilder {
|
pub fn insert<K: StrAllocating, V: ToJson>(self, key: K, value: V) -> ObjectBuilder {
|
||||||
let mut builder = self;
|
let mut builder = self;
|
||||||
builder.object.insert(key, value.to_json());
|
builder.object.insert(key.into_string(), value.to_json());
|
||||||
builder
|
builder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -639,3 +639,9 @@ impl<A:ToJson> ToJson for Option<A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, T: ToJson> ToJson for &'a T {
|
||||||
|
fn to_json(&self) -> Value {
|
||||||
|
(*self).to_json()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user