update trait impl

This commit is contained in:
2022-05-15 10:28:22 +08:00
parent 886f05aa12
commit 50122f6450
2 changed files with 10 additions and 10 deletions

View File

@@ -10,12 +10,6 @@ impl ToJson for &str {
}
}
impl ToJson for &String {
fn to_json(&self) -> Option<JsonValue> {
Some(JsonValue::String((*self).to_string()))
}
}
impl ToJson for String {
fn to_json(&self) -> Option<JsonValue> {
Some(JsonValue::String(self.to_string()))
@@ -28,9 +22,9 @@ impl ToJson for JsonValue {
}
}
impl ToJson for &JsonValue {
impl<T: ToJson> ToJson for &T {
fn to_json(&self) -> Option<JsonValue> {
Some((*self).clone())
(*self).to_json()
}
}