mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-18 09:41:12 +00:00
WIP
This commit is contained in:
+10
-2
@@ -3,7 +3,6 @@
|
|||||||
use std::ops;
|
use std::ops;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ascii;
|
use std::ascii;
|
||||||
use std::char;
|
|
||||||
|
|
||||||
use ser;
|
use ser;
|
||||||
use de;
|
use de;
|
||||||
@@ -91,6 +90,15 @@ impl fmt::Debug for ByteBuf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Disabled: triggers conflict with From implementation below
|
||||||
|
impl Into<Vec<u8>> for ByteBuf {
|
||||||
|
fn into(self) -> Vec<u8> {
|
||||||
|
self.bytes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
impl<T> From<T> for ByteBuf where T: Into<Vec<u8>> {
|
impl<T> From<T> for ByteBuf where T: Into<Vec<u8>> {
|
||||||
fn from(bytes: T) -> Self {
|
fn from(bytes: T) -> Self {
|
||||||
ByteBuf {
|
ByteBuf {
|
||||||
@@ -205,7 +213,7 @@ fn escape_bytestring(bytes: &[u8]) -> String {
|
|||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
for &b in bytes {
|
for &b in bytes {
|
||||||
for esc in ascii::escape_default(b) {
|
for esc in ascii::escape_default(b) {
|
||||||
result.push(char::from_u32(esc as u32).unwrap());
|
result.push(esc as char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
|||||||
Reference in New Issue
Block a user