Rocket

A web framework for Rust. https://rocket.rs (mirror)
git clone git://git.thc420.xyz/Rocket
Log | Files | Refs | README

commit fd05f998ab47f4bdeac1a09566910743abbc6b2d
parent d07628e0e478817bdda1be0f2e19c2fcb24c4f04
Author: Adam <adam.and.math@gmail.com>
Date:   Wed, 10 Apr 2019 20:37:11 +0200

Implement 'FromIterator' for 'JsonValue'.

Diffstat:
Mcontrib/lib/src/json.rs | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/contrib/lib/src/json.rs b/contrib/lib/src/json.rs @@ -19,6 +19,7 @@ extern crate serde_json; use std::ops::{Deref, DerefMut}; use std::io::{self, Read}; +use std::iter::FromIterator; use rocket::request::Request; use rocket::outcome::Outcome::*; @@ -277,6 +278,12 @@ impl From<serde_json::Value> for JsonValue { } } +impl<T> FromIterator<T> for JsonValue where serde_json::Value: FromIterator<T> { + fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self { + JsonValue(serde_json::Value::from_iter(iter)) + } +} + /// Serializes the value into JSON. Returns a response with Content-Type JSON /// and a fixed-size body with the serialized value. impl<'a> Responder<'a> for JsonValue {