Preserve argument names

This commit is contained in:
Caio
2019-03-14 08:46:42 -03:00
parent 90c3196b7b
commit 70f5373348
10 changed files with 97 additions and 14 deletions

View File

@ -46,6 +46,15 @@ impl<'src> Decode<'src> for &'src str {
}
}
impl<'src> Decode<'src> for String {
fn decode(data: &mut &'src [u8]) -> String {
let n = u32::decode(data);
let (a, b) = data.split_at(n as usize);
*data = b;
String::from_utf8(a.to_vec()).unwrap()
}
}
impl<'src, T: Decode<'src>> Decode<'src> for Vec<T> {
fn decode(data: &mut &'src [u8]) -> Self {
let n = u32::decode(data);