Implement 'FromIterator' for 'JsonValue'.

This commit is contained in:
Adam 2019-04-10 20:37:11 +02:00 committed by Jeb Rosen
parent d07628e0e4
commit fd05f998ab
1 changed files with 7 additions and 0 deletions

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 {