use iter::Iterator;
use option::{Option, None, Some};
use str::StrSlice;
-use slice::{MutableCloneableVector, ImmutableVector, MutableVector};
+use slice::{MutableCloneableSlice, ImmutableSlice, MutableSlice};
pub type Port = u16;
// Return result of first successful parser
fn read_or<T>(&mut self, parsers: &mut [|&mut Parser| -> Option<T>])
-> Option<T> {
- for pf in parsers.mut_iter() {
+ for pf in parsers.iter_mut() {
match self.read_atomically(|p: &mut Parser| (*pf)(p)) {
Some(r) => return Some(r),
None => {}
fn parse_digit(c: char, radix: u8) -> Option<u8> {
let c = c as u8;
// assuming radix is either 10 or 16
- if c >= '0' as u8 && c <= '9' as u8 {
- Some(c - '0' as u8)
- } else if radix > 10 && c >= 'a' as u8 && c < 'a' as u8 + (radix - 10) {
- Some(c - 'a' as u8 + 10)
- } else if radix > 10 && c >= 'A' as u8 && c < 'A' as u8 + (radix - 10) {
- Some(c - 'A' as u8 + 10)
+ if c >= b'0' && c <= b'9' {
+ Some(c - b'0')
+ } else if radix > 10 && c >= b'a' && c < b'a' + (radix - 10) {
+ Some(c - b'a' + 10)
+ } else if radix > 10 && c >= b'A' && c < b'A' + (radix - 10) {
+ Some(c - b'A' + 10)
} else {
None
}
assert!(head.len() + tail.len() <= 8);
let mut gs = [0u16, ..8];
gs.copy_from(head);
- gs.mut_slice(8 - tail.len(), 8).copy_from(tail);
+ gs.slice_mut(8 - tail.len(), 8).copy_from(tail);
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
}
}
#[test]
- fn ipv6_addr_to_str() {
+ fn ipv6_addr_to_string() {
let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280);
- assert!(a1.to_str() == "::ffff:192.0.2.128".to_string() ||
- a1.to_str() == "::FFFF:192.0.2.128".to_string());
- assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), "8:9:a:b:c:d:e:f".to_string());
+ assert!(a1.to_string() == "::ffff:192.0.2.128".to_string() ||
+ a1.to_string() == "::FFFF:192.0.2.128".to_string());
+ assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_string(),
+ "8:9:a:b:c:d:e:f".to_string());
}
}