From 0b192cfda657f0b9e5d4b92540cf9174b2f5bf94 Mon Sep 17 00:00:00 2001 From: Daniel Beckwith Date: Thu, 24 Nov 2022 22:02:14 +0000 Subject: [PATCH] Add From impls for Json --- sqlx-core/src/types/json.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sqlx-core/src/types/json.rs b/sqlx-core/src/types/json.rs index c0ef6b4d68..a8fd269012 100644 --- a/sqlx-core/src/types/json.rs +++ b/sqlx-core/src/types/json.rs @@ -57,6 +57,18 @@ use crate::types::Type; #[serde(transparent)] pub struct Json(pub T); +impl From for Json { + fn from(value: T) -> Self { + Self(value) + } +} + +impl From> for T { + fn from(Json(value): Json) -> Self { + value + } +} + impl Deref for Json { type Target = T;