From db3dffa721b6650cab630002faab54105337b17f Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:24:04 -0800 Subject: [PATCH] Add ref Option conversion into ScVal (#320) * Add ref Option conversion into ScVal * add to next --- src/curr/scval_conversions.rs | 12 ++++++++++++ src/next/scval_conversions.rs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/curr/scval_conversions.rs b/src/curr/scval_conversions.rs index 01f48286..0856ab81 100644 --- a/src/curr/scval_conversions.rs +++ b/src/curr/scval_conversions.rs @@ -559,6 +559,18 @@ impl> From> for ScVal { } } +impl From<&Option> for ScVal +where + for<'a> &'a T: Into, +{ + fn from(v: &Option) -> Self { + match v { + Some(v) => v.into(), + None => ().into(), + } + } +} + macro_rules! impl_for_tuple { ( $count:literal $($typ:ident $idx:tt)+ ) => { #[cfg(feature = "alloc")] diff --git a/src/next/scval_conversions.rs b/src/next/scval_conversions.rs index 01f48286..0856ab81 100644 --- a/src/next/scval_conversions.rs +++ b/src/next/scval_conversions.rs @@ -559,6 +559,18 @@ impl> From> for ScVal { } } +impl From<&Option> for ScVal +where + for<'a> &'a T: Into, +{ + fn from(v: &Option) -> Self { + match v { + Some(v) => v.into(), + None => ().into(), + } + } +} + macro_rules! impl_for_tuple { ( $count:literal $($typ:ident $idx:tt)+ ) => { #[cfg(feature = "alloc")]