Skip to content

Commit

Permalink
make Value be From<Option<T>>
Browse files Browse the repository at this point in the history
  • Loading branch information
kvnvelasco committed Jun 24, 2022
1 parent 3d17340 commit 1bf61e9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/value/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,15 @@ impl From<()> for Value {
Value::Null
}
}

impl<T> From<Option<T>> for Value
where
T: Into<Value>,
{
fn from(opt: Option<T>) -> Self {
match opt {
None => Self::Null,
Some(value) => Into::into(value),
}
}
}

0 comments on commit 1bf61e9

Please sign in to comment.