undo the breaking change introduced in 0.7.6

This commit is contained in:
Oliver Schneider
2016-06-01 11:08:59 +02:00
parent e0bd57d63c
commit 96cd910c92
6 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "serde"
version = "0.7.6"
version = "0.7.7"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A generic serialization/deserialization framework"
+1 -1
View File
@@ -578,7 +578,7 @@ pub trait Visitor {
fn visit_char<E>(&mut self, v: char) -> Result<Self::Value, E>
where E: Error,
{
self.visit_str(::core::str::from_utf8(::utils::encode_utf8(v).as_slice()).unwrap())
self.visit_str(::utils::encode_utf8(v).as_str())
}
/// `visit_str` deserializes a `&str` into a `Value`.
+3 -3
View File
@@ -122,11 +122,11 @@ pub trait Serializer {
/// Serializes a `f64` value.
fn serialize_f64(&mut self, v: f64) -> Result<(), Self::Error>;
/// Serializes a character. By default it serializes as bytes containing the UTF-8 encoding
/// of the character.
/// Serializes a character. By default it serializes it as a `&str` containing a
/// single character.
#[inline]
fn serialize_char(&mut self, v: char) -> Result<(), Self::Error> {
self.serialize_bytes(::utils::encode_utf8(v).as_slice())
self.serialize_str(::utils::encode_utf8(v).as_str())
}
/// Serializes a `&str`.
+3 -3
View File
@@ -40,9 +40,9 @@ pub struct EncodeUtf8 {
}
impl EncodeUtf8 {
/// Returns the remaining bytes of this iterator as a slice.
pub fn as_slice(&self) -> &[u8] {
&self.buf[self.pos..]
// FIXME: use this from_utf8_unchecked, since we know it can never fail
pub fn as_str(&self) -> &str {
::core::str::from_utf8(&self.buf[self.pos..]).unwrap()
}
}