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()
}
}

View File

@@ -58,9 +58,9 @@ impl ToJson for PixivID {
}
}
impl ToPixivID for &PixivID {
impl ToPixivID for PixivID {
fn to_pixiv_id(&self) -> Option<PixivID> {
Some((*self).clone())
Some(self.clone())
}
}
@@ -82,6 +82,12 @@ impl ToPixivID for u64 {
}
}
impl<T: ToPixivID> ToPixivID for &T {
fn to_pixiv_id(&self) -> Option<PixivID> {
(*self).to_pixiv_id()
}
}
impl TryInto<u64> for PixivID {
type Error = ();
fn try_into(self) -> Result<u64, Self::Error> {