Skip to content

Commit bf8cc66

Browse files
authored
Merge pull request #585 from Nilix007/add_from_unit_for_value
Add `impl From<()> for Value`
2 parents 7dda823 + ff5a59c commit bf8cc66

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/value/from.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,19 @@ impl<T: Into<Value>> ::std::iter::FromIterator<T> for Value {
211211
Value::Array(iter.into_iter().map(Into::into).collect())
212212
}
213213
}
214+
215+
impl From<()> for Value {
216+
/// Convert `()` to `Value`
217+
///
218+
/// # Examples
219+
///
220+
/// ```edition2018
221+
/// use serde_json::Value;
222+
///
223+
/// let u = ();
224+
/// let x: Value = u.into();
225+
/// ```
226+
fn from((): ()) -> Self {
227+
Value::Null
228+
}
229+
}

0 commit comments

Comments
 (0)