Fix: String::from_utf8 changed function signature

Following a rust std change.
This commit is contained in:
Thomas Bahn
2014-12-23 16:45:32 +01:00
parent 3cf0fb8d5b
commit 91cfb003d9
+3 -2
View File
@@ -2,6 +2,7 @@ use std::f32;
use std::f64; use std::f64;
use std::num::{Float, FPNaN, FPInfinite}; use std::num::{Float, FPNaN, FPInfinite};
use std::io::{IoError, IoResult}; use std::io::{IoError, IoResult};
use std::str::Utf8Error;
use ser::Serialize; use ser::Serialize;
use ser; use ser;
@@ -599,7 +600,7 @@ pub fn to_vec<
#[inline] #[inline]
pub fn to_string< pub fn to_string<
T: Serialize<Serializer<Vec<u8>>, IoError> T: Serialize<Serializer<Vec<u8>>, IoError>
>(value: &T) -> Result<String, Vec<u8>> { >(value: &T) -> Result<String, (Vec<u8>, Utf8Error)> {
let buf = to_vec(value); let buf = to_vec(value);
String::from_utf8(buf) String::from_utf8(buf)
} }
@@ -628,7 +629,7 @@ pub fn to_pretty_vec<
/// Encode the specified struct into a json `String` buffer. /// Encode the specified struct into a json `String` buffer.
pub fn to_pretty_string< pub fn to_pretty_string<
T: Serialize<PrettySerializer<Vec<u8>>, IoError> T: Serialize<PrettySerializer<Vec<u8>>, IoError>
>(value: &T) -> Result<String, Vec<u8>> { >(value: &T) -> Result<String, (Vec<u8>, Utf8Error)> {
let buf = to_pretty_vec(value); let buf = to_pretty_vec(value);
String::from_utf8(buf) String::from_utf8(buf)
} }