libserialize: remove unnecessary as_slice()
calls
This commit is contained in:
parent
e6bd217ce8
commit
09f7713dd4
@ -298,7 +298,6 @@ mod tests {
|
||||
#[test]
|
||||
fn test_to_base64_line_break() {
|
||||
assert!(![0u8, ..1000].to_base64(Config {line_length: None, ..STANDARD})
|
||||
.as_slice()
|
||||
.contains("\r\n"));
|
||||
assert_eq!("foobar".as_bytes().to_base64(Config {line_length: Some(4),
|
||||
..STANDARD}),
|
||||
@ -319,26 +318,26 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_from_base64_basic() {
|
||||
assert_eq!("".from_base64().unwrap().as_slice(), "".as_bytes());
|
||||
assert_eq!("Zg==".from_base64().unwrap().as_slice(), "f".as_bytes());
|
||||
assert_eq!("Zm8=".from_base64().unwrap().as_slice(), "fo".as_bytes());
|
||||
assert_eq!("Zm9v".from_base64().unwrap().as_slice(), "foo".as_bytes());
|
||||
assert_eq!("Zm9vYg==".from_base64().unwrap().as_slice(), "foob".as_bytes());
|
||||
assert_eq!("Zm9vYmE=".from_base64().unwrap().as_slice(), "fooba".as_bytes());
|
||||
assert_eq!("Zm9vYmFy".from_base64().unwrap().as_slice(), "foobar".as_bytes());
|
||||
assert_eq!("".from_base64().unwrap(), b"");
|
||||
assert_eq!("Zg==".from_base64().unwrap(), b"f");
|
||||
assert_eq!("Zm8=".from_base64().unwrap(), b"fo");
|
||||
assert_eq!("Zm9v".from_base64().unwrap(), b"foo");
|
||||
assert_eq!("Zm9vYg==".from_base64().unwrap(), b"foob");
|
||||
assert_eq!("Zm9vYmE=".from_base64().unwrap(), b"fooba");
|
||||
assert_eq!("Zm9vYmFy".from_base64().unwrap(), b"foobar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_base64_bytes() {
|
||||
assert_eq!(b"Zm9vYmFy".from_base64().unwrap().as_slice(), "foobar".as_bytes());
|
||||
assert_eq!(b"Zm9vYmFy".from_base64().unwrap(), b"foobar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_base64_newlines() {
|
||||
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap().as_slice(),
|
||||
"foobar".as_bytes());
|
||||
assert_eq!("Zm9vYg==\r\n".from_base64().unwrap().as_slice(),
|
||||
"foob".as_bytes());
|
||||
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(),
|
||||
b"foobar");
|
||||
assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(),
|
||||
b"foob");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -364,13 +363,10 @@ mod tests {
|
||||
for _ in range(0u, 1000) {
|
||||
let times = task_rng().gen_range(1u, 100);
|
||||
let v = Vec::from_fn(times, |_| random::<u8>());
|
||||
assert_eq!(v.as_slice()
|
||||
.to_base64(STANDARD)
|
||||
.as_slice()
|
||||
assert_eq!(v.to_base64(STANDARD)
|
||||
.from_base64()
|
||||
.unwrap()
|
||||
.as_slice(),
|
||||
v.as_slice());
|
||||
.unwrap(),
|
||||
v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +386,7 @@ mod tests {
|
||||
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン";
|
||||
let sb = s.as_bytes().to_base64(STANDARD);
|
||||
b.iter(|| {
|
||||
sb.as_slice().from_base64().unwrap();
|
||||
sb.from_base64().unwrap();
|
||||
});
|
||||
b.bytes = sb.len() as u64;
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_from_hex_okay() {
|
||||
assert_eq!("666f6f626172".from_hex().unwrap().as_slice(),
|
||||
"foobar".as_bytes());
|
||||
assert_eq!("666F6F626172".from_hex().unwrap().as_slice(),
|
||||
"foobar".as_bytes());
|
||||
assert_eq!("666f6f626172".from_hex().unwrap(),
|
||||
b"foobar");
|
||||
assert_eq!("666F6F626172".from_hex().unwrap(),
|
||||
b"foobar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -182,8 +182,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_from_hex_ignores_whitespace() {
|
||||
assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap().as_slice(),
|
||||
"foobar".as_bytes());
|
||||
assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(),
|
||||
b"foobar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -197,15 +197,11 @@ mod tests {
|
||||
pub fn test_from_hex_all_bytes() {
|
||||
for i in range(0u, 256) {
|
||||
let ii: &[u8] = &[i as u8];
|
||||
assert_eq!(format!("{:02x}", i as uint).as_slice()
|
||||
.from_hex()
|
||||
.unwrap()
|
||||
.as_slice(),
|
||||
assert_eq!(format!("{:02x}", i as uint).from_hex()
|
||||
.unwrap(),
|
||||
ii);
|
||||
assert_eq!(format!("{:02X}", i as uint).as_slice()
|
||||
.from_hex()
|
||||
.unwrap()
|
||||
.as_slice(),
|
||||
assert_eq!(format!("{:02X}", i as uint).from_hex()
|
||||
.unwrap(),
|
||||
ii);
|
||||
}
|
||||
}
|
||||
@ -226,7 +222,7 @@ mod tests {
|
||||
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン";
|
||||
let sb = s.as_bytes().to_hex();
|
||||
b.iter(|| {
|
||||
sb.as_slice().from_hex().unwrap();
|
||||
sb.from_hex().unwrap();
|
||||
});
|
||||
b.bytes = sb.len() as u64;
|
||||
}
|
||||
|
@ -2039,7 +2039,7 @@ impl ::Decoder<DecoderError> for Decoder {
|
||||
fn read_char(&mut self) -> DecodeResult<char> {
|
||||
let s = try!(self.read_str());
|
||||
{
|
||||
let mut it = s.as_slice().chars();
|
||||
let mut it = s.chars();
|
||||
match (it.next(), it.next()) {
|
||||
// exactly one character
|
||||
(Some(c), None) => return Ok(c),
|
||||
@ -2860,7 +2860,7 @@ mod tests {
|
||||
|
||||
for &(i, o) in s.iter() {
|
||||
let v: string::String = super::decode(i).unwrap();
|
||||
assert_eq!(v.as_slice(), o);
|
||||
assert_eq!(v, o);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3778,7 +3778,7 @@ mod tests {
|
||||
fn bench_streaming_large(b: &mut Bencher) {
|
||||
let src = big_json();
|
||||
b.iter( || {
|
||||
let mut parser = Parser::new(src.as_slice().chars());
|
||||
let mut parser = Parser::new(src.chars());
|
||||
loop {
|
||||
match parser.next() {
|
||||
None => return,
|
||||
|
Loading…
Reference in New Issue
Block a user