Merge pull request #585 from Nilix007/add_from_unit_for_value

Add `impl From<()> for Value`
This commit is contained in:
David Tolnay 2019-11-24 14:27:53 -08:00 committed by GitHub
commit bf8cc6642f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -211,3 +211,19 @@ impl<T: Into<Value>> ::std::iter::FromIterator<T> for Value {
Value::Array(iter.into_iter().map(Into::into).collect())
}
}
impl From<()> for Value {
/// Convert `()` to `Value`
///
/// # Examples
///
/// ```edition2018
/// use serde_json::Value;
///
/// let u = ();
/// let x: Value = u.into();
/// ```
fn from((): ()) -> Self {
Value::Null
}
}