Skip to content

Commit

Permalink
Merge pull request #900 from kvnvelasco/implement_from_option_for_value
Browse files Browse the repository at this point in the history
Make Value be From<Option<T>>
  • Loading branch information
dtolnay committed Jun 29, 2022
2 parents 3d17340 + b87778b commit df704c2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/value/from.rs
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 => Value::Null,
Some(value) => Into::into(value),
}
}
}

0 comments on commit df704c2

Please sign in to comment.