Skip to content

Commit

Permalink
Merge pull request #585 from Nilix007/add_from_unit_for_value
Browse files Browse the repository at this point in the history
Add `impl From<()> for Value`
  • Loading branch information
dtolnay committed Nov 24, 2019
2 parents 7dda823 + ff5a59c commit bf8cc66
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/value/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit bf8cc66

Please sign in to comment.