Skip to content

Commit

Permalink
Add ref Option conversion into ScVal (#320)
Browse files Browse the repository at this point in the history
* Add ref Option conversion into ScVal

* add to next
  • Loading branch information
leighmcculloch authored Nov 13, 2023
1 parent 957273d commit db3dffa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/curr/scval_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,18 @@ impl<T: Into<ScVal>> From<Option<T>> for ScVal {
}
}

impl<T> From<&Option<T>> for ScVal
where
for<'a> &'a T: Into<ScVal>,
{
fn from(v: &Option<T>) -> Self {
match v {
Some(v) => v.into(),
None => ().into(),
}
}
}

macro_rules! impl_for_tuple {
( $count:literal $($typ:ident $idx:tt)+ ) => {
#[cfg(feature = "alloc")]
Expand Down
12 changes: 12 additions & 0 deletions src/next/scval_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,18 @@ impl<T: Into<ScVal>> From<Option<T>> for ScVal {
}
}

impl<T> From<&Option<T>> for ScVal
where
for<'a> &'a T: Into<ScVal>,
{
fn from(v: &Option<T>) -> Self {
match v {
Some(v) => v.into(),
None => ().into(),
}
}
}

macro_rules! impl_for_tuple {
( $count:literal $($typ:ident $idx:tt)+ ) => {
#[cfg(feature = "alloc")]
Expand Down

0 comments on commit db3dffa

Please sign in to comment.