Use byte literals in libserialize

This commit is contained in:
nham 2014-08-06 01:07:10 -04:00
parent f36ddf1d0e
commit d45a569995
2 changed files with 10 additions and 10 deletions
src/libserialize

@ -89,8 +89,8 @@ impl<'a> ToBase64 for &'a [u8] {
match config.line_length {
Some(line_length) =>
if cur_length >= line_length {
v.push('\r' as u8);
v.push('\n' as u8);
v.push(b'\r');
v.push(b'\n');
cur_length = 0;
},
None => ()
@ -114,8 +114,8 @@ impl<'a> ToBase64 for &'a [u8] {
match config.line_length {
Some(line_length) =>
if cur_length >= line_length {
v.push('\r' as u8);
v.push('\n' as u8);
v.push(b'\r');
v.push(b'\n');
},
None => ()
}
@ -130,8 +130,8 @@ impl<'a> ToBase64 for &'a [u8] {
v.push(bytes[((n >> 18) & 63) as uint]);
v.push(bytes[((n >> 12) & 63) as uint]);
if config.pad {
v.push('=' as u8);
v.push('=' as u8);
v.push(b'=');
v.push(b'=');
}
}
2 => {
@ -141,7 +141,7 @@ impl<'a> ToBase64 for &'a [u8] {
v.push(bytes[((n >> 12) & 63) as uint]);
v.push(bytes[((n >> 6 ) & 63) as uint]);
if config.pad {
v.push('=' as u8);
v.push(b'=');
}
}
_ => fail!("Algebra is broken, please alert the math police")

@ -113,9 +113,9 @@ impl<'a> FromHex for &'a str {
buf <<= 4;
match byte as char {
'A'..'F' => buf |= byte - ('A' as u8) + 10,
'a'..'f' => buf |= byte - ('a' as u8) + 10,
'0'..'9' => buf |= byte - ('0' as u8),
'A'..'F' => buf |= byte - b'A' + 10,
'a'..'f' => buf |= byte - b'a' + 10,
'0'..'9' => buf |= byte - b'0',
' '|'\r'|'\n'|'\t' => {
buf >>= 4;
continue