From 5df9aeda41d4ab848191d004ab864fdf8ac6488c Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Mon, 28 Dec 2020 16:05:06 +0200 Subject: [PATCH] Add impl From for Value Addresses #736 --- src/value/from.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/value/from.rs b/src/value/from.rs index 4423a02fb..2fe8037bb 100644 --- a/src/value/from.rs +++ b/src/value/from.rs @@ -136,6 +136,22 @@ impl<'a> From> for Value { } } +impl From 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> for Value { /// Convert map (with string keys) to `Value` ///