Implement 'FromIterator' for 'JsonValue'.

This commit is contained in:
Adam 2019-04-10 20:37:11 +02:00 committed by Sergio Benitez
parent 3e3fe56e6a
commit 233121b6dc

View File

@ -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 {