Skip to content

Commit

Permalink
Merge pull request #737 from imp/value_from_number
Browse files Browse the repository at this point in the history
Add impl From<Number> for Value
  • Loading branch information
dtolnay committed Dec 28, 2020
2 parents 5a815a5 + 5df9aed commit e63aedb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/value/from.rs
Expand Up @@ -136,6 +136,22 @@ impl<'a> From<Cow<'a, str>> for Value {
}
}

impl From<Number> for Value {
/// Convert `Number` to `Value`
///
/// # Examples
///
/// ```
/// use serde_json::{Number, Value};
///
/// let n = Number::from(7);
/// let x: Value = n.into();
/// ```
fn from(f: Number) -> Self {
Value::Number(f)
}
}

impl From<Map<String, Value>> for Value {
/// Convert map (with string keys) to `Value`
///
Expand Down

0 comments on commit e63aedb

Please sign in to comment.