Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ addons:
rust:
- nightly
- stable
- 1.13.0
- 1.16.0
- 1.17.0

before_script:
- |
Expand Down
7 changes: 3 additions & 4 deletions rmp-serde/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,9 @@ impl<'a, W: Write, V: VariantWriter> serde::Serializer for &'a mut Serializer<W,
}

fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error> {
// TODO: The implementation involves heap allocation and is unstable.
let mut buf = String::new();
buf.push(v);
self.serialize_str(&buf)
// A char encoded as UTF-8 takes 4 bytes at most.
let mut buf = [0; 4];
self.serialize_str(v.encode_utf8(&mut buf))
}

fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> {
Expand Down
6 changes: 3 additions & 3 deletions rmp-serialize/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ impl<'a> rustc_serialize::Encoder for Encoder<'a> {

// TODO: The implementation involves heap allocation and is unstable.
fn emit_char(&mut self, val: char) -> Result<(), Error> {
let mut buf = String::new();
buf.push(val);
self.emit_str(&buf)
// A char encoded as UTF-8 takes 4 bytes at most.
let mut buf = [0; 4];
self.emit_str(val.encode_utf8(&mut buf))
}

fn emit_str(&mut self, val: &str) -> Result<(), Error> {
Expand Down