Skip to content

Commit

Permalink
Add impl From<Number> for Value
Browse files Browse the repository at this point in the history
Addresses #736
  • Loading branch information
imp committed Dec 28, 2020
1 parent 5a815a5 commit 5df9aed
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 @@ -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 5df9aed

Please sign in to comment.