1
Fork 0

[breaking-change] std: change encode_utf{8,16}() to take a buffer and return a slice

They panic if the buffer is too small.
This commit is contained in:
tormol 2016-09-08 13:54:39 +02:00
parent a059cb2f33
commit 13a2dd96fe
9 changed files with 163 additions and 188 deletions

View file

@ -433,9 +433,7 @@ fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult {
}
fn escape_char(writer: &mut fmt::Write, v: char) -> EncodeResult {
escape_str(writer, unsafe {
str::from_utf8_unchecked(v.encode_utf8().as_slice())
})
escape_str(writer, v.encode_utf8(&mut [0; 4]))
}
fn spaces(wr: &mut fmt::Write, mut n: usize) -> EncodeResult {