Skip to content

Commit df704c2

Browse files
authored
Merge pull request #900 from kvnvelasco/implement_from_option_for_value
Make Value be From<Option<T>>
2 parents 3d17340 + b87778b commit df704c2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/value/from.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,15 @@ impl From<()> for Value {
268268
Value::Null
269269
}
270270
}
271+
272+
impl<T> From<Option<T>> for Value
273+
where
274+
T: Into<Value>,
275+
{
276+
fn from(opt: Option<T>) -> Self {
277+
match opt {
278+
None => Value::Null,
279+
Some(value) => Into::into(value),
280+
}
281+
}
282+
}

0 commit comments

Comments
 (0)