Skip to content

Commit

Permalink
Add From impls for Json
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeckwith authored and abonander committed Mar 10, 2023
1 parent 5a8cd95 commit 0b192cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sqlx-core/src/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ use crate::types::Type;
#[serde(transparent)]
pub struct Json<T: ?Sized>(pub T);

impl<T> From<T> for Json<T> {
fn from(value: T) -> Self {
Self(value)
}
}

impl<T> From<Json<T>> for T {
fn from(Json(value): Json<T>) -> Self {
value
}
}

impl<T> Deref for Json<T> {
type Target = T;

Expand Down

0 comments on commit 0b192cf

Please sign in to comment.