From 1bf61e9c087c33cc13063b538678120b2ca1d8e3 Mon Sep 17 00:00:00 2001 From: Kevin Velasco Date: Fri, 24 Jun 2022 10:58:58 +0800 Subject: [PATCH 1/2] make Value be From> --- src/value/from.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/value/from.rs b/src/value/from.rs index 7b37ef688..bd137b4cf 100644 --- a/src/value/from.rs +++ b/src/value/from.rs @@ -268,3 +268,15 @@ impl From<()> for Value { Value::Null } } + +impl From> for Value +where + T: Into, +{ + fn from(opt: Option) -> Self { + match opt { + None => Self::Null, + Some(value) => Into::into(value), + } + } +} From b87778bf54dd4d7dc63aacd4c1d7f48e33317fa2 Mon Sep 17 00:00:00 2001 From: Kevin Velasco Date: Fri, 24 Jun 2022 11:20:05 +0800 Subject: [PATCH 2/2] don't use experimental (in 1.36) Self:: access for enums --- src/value/from.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/value/from.rs b/src/value/from.rs index bd137b4cf..858a6e48a 100644 --- a/src/value/from.rs +++ b/src/value/from.rs @@ -275,7 +275,7 @@ where { fn from(opt: Option) -> Self { match opt { - None => Self::Null, + None => Value::Null, Some(value) => Into::into(value), } }