Updated for Rust master.

This commit is contained in:
Aaron Weiss 2015-02-21 09:28:12 -05:00
parent e5fe45c9de
commit dd4635d39f
8 changed files with 273 additions and 273 deletions

View file

@ -36,7 +36,7 @@ impl Connection<BufferedReader<NetStream>, BufferedWriter<NetStream>> {
/// connects to the specified server and returns a reader-writer pair.
fn connect_internal(host: &str, port: u16) -> IoResult<NetReaderWriterPair> {
let socket = try!(TcpStream::connect(&format!("{}:{}", host, port)[]));
let socket = try!(TcpStream::connect(&format!("{}:{}", host, port)[..]));
Ok((BufferedReader::new(NetStream::UnsecuredTcpStream(socket.clone())),
BufferedWriter::new(NetStream::UnsecuredTcpStream(socket))))
}
@ -52,7 +52,7 @@ impl Connection<BufferedReader<NetStream>, BufferedWriter<NetStream>> {
/// Connects over SSL to the specified server and returns a reader-writer pair.
#[cfg(feature = "ssl")]
fn connect_ssl_internal(host: &str, port: u16) -> IoResult<NetReaderWriterPair> {
let socket = try!(TcpStream::connect(&format!("{}:{}", host, port)[]));
let socket = try!(TcpStream::connect(&format!("{}:{}", host, port)[..]));
let ssl = try!(ssl_to_io(SslContext::new(SslMethod::Tlsv1)));
let ssl_socket = try!(ssl_to_io(SslStream::new(&ssl, socket)));
Ok((BufferedReader::new(NetStream::SslTcpStream(ssl_socket.clone())),
@ -129,7 +129,7 @@ impl<T: IrcReader, U: IrcWriter> Connection<T, U> {
})
};
let msg = to_msg.to_message();
let data = match encoding.encode(&msg.into_string()[], EncoderTrap::Replace) {
let data = match encoding.encode(&msg.into_string(), EncoderTrap::Replace) {
Ok(data) => data,
Err(data) => return Err(IoError {
kind: IoErrorKind::InvalidInput,
@ -138,7 +138,7 @@ impl<T: IrcReader, U: IrcWriter> Connection<T, U> {
})
};
let mut writer = self.writer.lock().unwrap();
try!(writer.write_all(&data[]));
try!(writer.write_all(&data));
writer.flush()
}
@ -164,7 +164,7 @@ impl<T: IrcReader, U: IrcWriter> Connection<T, U> {
})
};
self.reader.lock().unwrap().read_until(b'\n').and_then(|line|
match encoding.decode(&line[], DecoderTrap::Replace) {
match encoding.decode(&line, DecoderTrap::Replace) {
Ok(data) => Ok(data),
Err(data) => Err(IoError {
kind: IoErrorKind::InvalidInput,

View file

@ -325,277 +325,277 @@ impl<'a> Command<'a> {
/// Converts a Message into a Command.
#[stable]
pub fn from_message(m: &'a Message) -> IoResult<Command<'a>> {
Ok(if let "PASS" = &m.command[] {
Ok(if let "PASS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::PASS(&suffix[])
Command::PASS(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::PASS(&m.args[0][])
Command::PASS(&m.args[0])
}
}
} else if let "NICK" = &m.command[] {
} else if let "NICK" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::NICK(&suffix[])
Command::NICK(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::NICK(&m.args[0][])
Command::NICK(&m.args[0])
}
}
} else if let "USER" = &m.command[] {
} else if let "USER" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::USER(&m.args[0][], &m.args[1][], &suffix[])
Command::USER(&m.args[0], &m.args[1], &suffix)
},
None => {
if m.args.len() != 3 { return Err(invalid_input()) }
Command::USER(&m.args[0][], &m.args[1][], &m.args[2][])
Command::USER(&m.args[0], &m.args[1], &m.args[2])
}
}
} else if let "OPER" = &m.command[] {
} else if let "OPER" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::OPER(&m.args[0][], &suffix[])
Command::OPER(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::OPER(&m.args[0][], &m.args[1][])
Command::OPER(&m.args[0], &m.args[1])
}
}
} else if let "MODE" = &m.command[] {
} else if let "MODE" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::MODE(&m.args[0][], &m.args[1][], Some(&suffix[]))
Command::MODE(&m.args[0], &m.args[1], Some(&suffix))
}
None => if m.args.len() == 3 {
Command::MODE(&m.args[0][], &m.args[1][], Some(&m.args[2][]))
Command::MODE(&m.args[0], &m.args[1], Some(&m.args[2]))
} else if m.args.len() == 2 {
Command::MODE(&m.args[0][], &m.args[1][], None)
Command::MODE(&m.args[0], &m.args[1], None)
} else {
return Err(invalid_input())
}
}
} else if let "SERVICE" = &m.command[] {
} else if let "SERVICE" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 5 { return Err(invalid_input()) }
Command::SERVICE(&m.args[0][], &m.args[1][], &m.args[2][], &m.args[3][],
&m.args[4][], &suffix[])
Command::SERVICE(&m.args[0], &m.args[1], &m.args[2], &m.args[3],
&m.args[4], &suffix)
},
None => {
if m.args.len() != 6 { return Err(invalid_input()) }
Command::SERVICE(&m.args[0][], &m.args[1][], &m.args[2][], &m.args[3][],
&m.args[4][], &m.args[5][])
Command::SERVICE(&m.args[0], &m.args[1], &m.args[2], &m.args[3],
&m.args[4], &m.args[5])
}
}
} else if let "QUIT" = &m.command[] {
} else if let "QUIT" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::QUIT(Some(&suffix[])),
Some(ref suffix) => Command::QUIT(Some(&suffix)),
None => Command::QUIT(None)
}
} else if let "SQUIT" = &m.command[] {
} else if let "SQUIT" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::SQUIT(&m.args[0][], &suffix[])
Command::SQUIT(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::SQUIT(&m.args[0][], &m.args[1][])
Command::SQUIT(&m.args[0], &m.args[1])
}
}
} else if let "JOIN" = &m.command[] {
} else if let "JOIN" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::JOIN(&suffix[], None)
Command::JOIN(&suffix, None)
} else if m.args.len() == 1 {
Command::JOIN(&m.args[0][], Some(&suffix[]))
Command::JOIN(&m.args[0], Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::JOIN(&m.args[0][], None)
Command::JOIN(&m.args[0], None)
} else if m.args.len() == 2 {
Command::JOIN(&m.args[0][], Some(&m.args[1][]))
Command::JOIN(&m.args[0], Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "PART" = &m.command[] {
} else if let "PART" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::PART(&suffix[], None)
Command::PART(&suffix, None)
} else if m.args.len() == 1 {
Command::PART(&m.args[0][], Some(&suffix[]))
Command::PART(&m.args[0], Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::PART(&m.args[0][], None)
Command::PART(&m.args[0], None)
} else if m.args.len() == 2 {
Command::PART(&m.args[0][], Some(&m.args[1][]))
Command::PART(&m.args[0], Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "TOPIC" = &m.command[] {
} else if let "TOPIC" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::TOPIC(&suffix[], None)
Command::TOPIC(&suffix, None)
} else if m.args.len() == 1 {
Command::TOPIC(&m.args[0][], Some(&suffix[]))
Command::TOPIC(&m.args[0], Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::TOPIC(&m.args[0][], None)
Command::TOPIC(&m.args[0], None)
} else if m.args.len() == 2 {
Command::TOPIC(&m.args[0][], Some(&m.args[1][]))
Command::TOPIC(&m.args[0], Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "NAMES" = &m.command[] {
} else if let "NAMES" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::NAMES(Some(&suffix[]), None)
Command::NAMES(Some(&suffix), None)
} else if m.args.len() == 1 {
Command::NAMES(Some(&m.args[0][]), Some(&suffix[]))
Command::NAMES(Some(&m.args[0]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 0 {
Command::NAMES(None, None)
} else if m.args.len() == 1 {
Command::NAMES(Some(&m.args[0][]), None)
Command::NAMES(Some(&m.args[0]), None)
} else if m.args.len() == 2 {
Command::NAMES(Some(&m.args[0][]), Some(&m.args[1][]))
Command::NAMES(Some(&m.args[0]), Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "LIST" = &m.command[] {
} else if let "LIST" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::LIST(Some(&suffix[]), None)
Command::LIST(Some(&suffix), None)
} else if m.args.len() == 1 {
Command::LIST(Some(&m.args[0][]), Some(&suffix[]))
Command::LIST(Some(&m.args[0]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 0 {
Command::LIST(None, None)
} else if m.args.len() == 1 {
Command::LIST(Some(&m.args[0][]), None)
Command::LIST(Some(&m.args[0]), None)
} else if m.args.len() == 2 {
Command::LIST(Some(&m.args[0][]), Some(&m.args[1][]))
Command::LIST(Some(&m.args[0]), Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "INVITE" = &m.command[] {
} else if let "INVITE" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::INVITE(&m.args[0][], &suffix[])
Command::INVITE(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::INVITE(&m.args[0][], &m.args[1][])
Command::INVITE(&m.args[0], &m.args[1])
}
}
} else if let "KICK" = &m.command[] {
} else if let "KICK" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::KICK(&m.args[0][], &m.args[1][], Some(&suffix[]))
Command::KICK(&m.args[0], &m.args[1], Some(&suffix))
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::KICK(&m.args[0][], &m.args[1][], None)
Command::KICK(&m.args[0], &m.args[1], None)
},
}
} else if let "PRIVMSG" = &m.command[] {
} else if let "PRIVMSG" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::PRIVMSG(&m.args[0][], &suffix[])
Command::PRIVMSG(&m.args[0], &suffix)
},
None => return Err(invalid_input())
}
} else if let "NOTICE" = &m.command[] {
} else if let "NOTICE" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::NOTICE(&m.args[0][], &suffix[])
Command::NOTICE(&m.args[0], &suffix)
},
None => return Err(invalid_input())
}
} else if let "MOTD" = &m.command[] {
} else if let "MOTD" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::MOTD(Some(&suffix[])),
Some(ref suffix) => Command::MOTD(Some(&suffix)),
None => Command::MOTD(None)
}
} else if let "LUSERS" = &m.command[] {
} else if let "LUSERS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::LUSERS(Some(&suffix[]), None)
Command::LUSERS(Some(&suffix), None)
} else if m.args.len() == 1 {
Command::LUSERS(Some(&m.args[0][]), Some(&suffix[]))
Command::LUSERS(Some(&m.args[0]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 0 {
Command::LUSERS(None, None)
} else if m.args.len() == 1 {
Command::LUSERS(Some(&m.args[0][]), None)
Command::LUSERS(Some(&m.args[0]), None)
} else if m.args.len() == 2 {
Command::LUSERS(Some(&m.args[0][]), Some(&m.args[1][]))
Command::LUSERS(Some(&m.args[0]), Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "VERSION" = &m.command[] {
} else if let "VERSION" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::VERSION(Some(&suffix[])),
Some(ref suffix) => Command::VERSION(Some(&suffix)),
None => Command::VERSION(None)
}
} else if let "STATS" = &m.command[] {
} else if let "STATS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::STATS(Some(&suffix[]), None)
Command::STATS(Some(&suffix), None)
} else if m.args.len() == 1 {
Command::STATS(Some(&m.args[0][]), Some(&suffix[]))
Command::STATS(Some(&m.args[0]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 0 {
Command::STATS(None, None)
} else if m.args.len() == 1 {
Command::STATS(Some(&m.args[0][]), None)
Command::STATS(Some(&m.args[0]), None)
} else if m.args.len() == 2 {
Command::STATS(Some(&m.args[0][]), Some(&m.args[1][]))
Command::STATS(Some(&m.args[0]), Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "LINKS" = &m.command[] {
} else if let "LINKS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::LINKS(None, Some(&suffix[]))
Command::LINKS(None, Some(&suffix))
} else if m.args.len() == 1 {
Command::LINKS(Some(&m.args[0][]), Some(&suffix[]))
Command::LINKS(Some(&m.args[0]), Some(&suffix))
} else {
return Err(invalid_input())
},
@ -605,396 +605,396 @@ impl<'a> Command<'a> {
return Err(invalid_input())
}
}
} else if let "TIME" = &m.command[] {
} else if let "TIME" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::TIME(Some(&suffix[])),
Some(ref suffix) => Command::TIME(Some(&suffix)),
None => Command::TIME(None)
}
} else if let "CONNECT" = &m.command[] {
} else if let "CONNECT" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::CONNECT(&m.args[0][], &m.args[1][], Some(&suffix[]))
Command::CONNECT(&m.args[0], &m.args[1], Some(&suffix))
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::CONNECT(&m.args[0][], &m.args[1][], None)
Command::CONNECT(&m.args[0], &m.args[1], None)
}
}
} else if let "TRACE" = &m.command[] {
} else if let "TRACE" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::TRACE(Some(&suffix[])),
Some(ref suffix) => Command::TRACE(Some(&suffix)),
None => Command::TRACE(None)
}
} else if let "ADMIN" = &m.command[] {
} else if let "ADMIN" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::ADMIN(Some(&suffix[])),
Some(ref suffix) => Command::ADMIN(Some(&suffix)),
None => Command::ADMIN(None)
}
} else if let "INFO" = &m.command[] {
} else if let "INFO" = &m.command[..] {
if m.args.len() != 0 { return Err(invalid_input()) }
match m.suffix {
Some(ref suffix) => Command::INFO(Some(&suffix[])),
Some(ref suffix) => Command::INFO(Some(&suffix)),
None => Command::INFO(None)
}
} else if let "SERVLIST" = &m.command[] {
} else if let "SERVLIST" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::SERVLIST(Some(&suffix[]), None)
Command::SERVLIST(Some(&suffix), None)
} else if m.args.len() == 1 {
Command::SERVLIST(Some(&m.args[0][]), Some(&suffix[]))
Command::SERVLIST(Some(&m.args[0]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 0 {
Command::SERVLIST(None, None)
} else if m.args.len() == 1 {
Command::SERVLIST(Some(&m.args[0][]), None)
Command::SERVLIST(Some(&m.args[0]), None)
} else if m.args.len() == 2 {
Command::SERVLIST(Some(&m.args[0][]), Some(&m.args[1][]))
Command::SERVLIST(Some(&m.args[0]), Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "SQUERY" = &m.command[] {
} else if let "SQUERY" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::SQUERY(&m.args[0][], &suffix[])
Command::SQUERY(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::SQUERY(&m.args[0][], &m.args[1][])
Command::SQUERY(&m.args[0], &m.args[1])
}
}
} else if let "WHO" = &m.command[] {
} else if let "WHO" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::WHO(Some(&suffix[]), None)
Command::WHO(Some(&suffix), None)
} else if m.args.len() == 1 {
Command::WHO(Some(&m.args[0][]), Some(&suffix[] == "o"))
Command::WHO(Some(&m.args[0]), Some(&suffix[..] == "o"))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 0 {
Command::WHO(None, None)
} else if m.args.len() == 1 {
Command::WHO(Some(&m.args[0][]), None)
Command::WHO(Some(&m.args[0]), None)
} else if m.args.len() == 2 {
Command::WHO(Some(&m.args[0][]), Some(&m.args[1][] == "o"))
Command::WHO(Some(&m.args[0]), Some(&m.args[1][..] == "o"))
} else {
return Err(invalid_input())
}
}
} else if let "WHOIS" = &m.command[] {
} else if let "WHOIS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::WHOIS(None, &suffix[])
Command::WHOIS(None, &suffix)
} else if m.args.len() == 1 {
Command::WHOIS(Some(&m.args[0][]), &suffix[])
Command::WHOIS(Some(&m.args[0]), &suffix)
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::WHOIS(None, &m.args[0][])
Command::WHOIS(None, &m.args[0])
} else if m.args.len() == 2 {
Command::WHOIS(Some(&m.args[0][]), &m.args[1][])
Command::WHOIS(Some(&m.args[0]), &m.args[1])
} else {
return Err(invalid_input())
}
}
} else if let "WHOWAS" = &m.command[] {
} else if let "WHOWAS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::WHOWAS(&suffix[], None, None)
Command::WHOWAS(&suffix, None, None)
} else if m.args.len() == 1 {
Command::WHOWAS(&m.args[0][], None, Some(&suffix[]))
Command::WHOWAS(&m.args[0], None, Some(&suffix))
} else if m.args.len() == 2 {
Command::WHOWAS(&m.args[0][], Some(&m.args[1][]), Some(&suffix[]))
Command::WHOWAS(&m.args[0], Some(&m.args[1]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::WHOWAS(&m.args[0][], None, None)
Command::WHOWAS(&m.args[0], None, None)
} else if m.args.len() == 2 {
Command::WHOWAS(&m.args[0][], None, Some(&m.args[1][]))
Command::WHOWAS(&m.args[0], None, Some(&m.args[1]))
} else if m.args.len() == 3 {
Command::WHOWAS(&m.args[0][], Some(&m.args[1][]), Some(&m.args[2][]))
Command::WHOWAS(&m.args[0], Some(&m.args[1]), Some(&m.args[2]))
} else {
return Err(invalid_input())
}
}
} else if let "KILL" = &m.command[] {
} else if let "KILL" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::KILL(&m.args[0][], &suffix[])
Command::KILL(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::KILL(&m.args[0][], &m.args[1][])
Command::KILL(&m.args[0], &m.args[1])
}
}
} else if let "PING" = &m.command[] {
} else if let "PING" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::PING(&suffix[], None)
Command::PING(&suffix, None)
} else if m.args.len() == 1 {
Command::PING(&m.args[0][], Some(&suffix[]))
Command::PING(&m.args[0], Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::PING(&m.args[0][], None)
Command::PING(&m.args[0], None)
} else if m.args.len() == 2 {
Command::PING(&m.args[0][], Some(&m.args[1][]))
Command::PING(&m.args[0], Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "PONG" = &m.command[] {
} else if let "PONG" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::PONG(&suffix[], None)
Command::PONG(&suffix, None)
} else if m.args.len() == 1 {
Command::PONG(&m.args[0][], Some(&suffix[]))
Command::PONG(&m.args[0], Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::PONG(&m.args[0][], None)
Command::PONG(&m.args[0], None)
} else if m.args.len() == 2 {
Command::PONG(&m.args[0][], Some(&m.args[1][]))
Command::PONG(&m.args[0], Some(&m.args[1]))
} else {
return Err(invalid_input())
}
}
} else if let "ERROR" = &m.command[] {
} else if let "ERROR" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::ERROR(&suffix[])
Command::ERROR(&suffix)
} else {
return Err(invalid_input())
},
None => return Err(invalid_input())
}
} else if let "AWAY" = &m.command[] {
} else if let "AWAY" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::AWAY(Some(&suffix[]))
Command::AWAY(Some(&suffix))
} else {
return Err(invalid_input())
},
None => return Err(invalid_input())
}
} else if let "REHASH" = &m.command[] {
} else if let "REHASH" = &m.command[..] {
if m.args.len() == 0 {
Command::REHASH
} else {
return Err(invalid_input())
}
} else if let "DIE" = &m.command[] {
} else if let "DIE" = &m.command[..] {
if m.args.len() == 0 {
Command::DIE
} else {
return Err(invalid_input())
}
} else if let "RESTART" = &m.command[] {
} else if let "RESTART" = &m.command[..] {
if m.args.len() == 0 {
Command::RESTART
} else {
return Err(invalid_input())
}
} else if let "SUMMON" = &m.command[] {
} else if let "SUMMON" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 0 {
Command::SUMMON(&suffix[], None, None)
Command::SUMMON(&suffix, None, None)
} else if m.args.len() == 1 {
Command::SUMMON(&m.args[0][], Some(&suffix[]), None)
Command::SUMMON(&m.args[0], Some(&suffix), None)
} else if m.args.len() == 2 {
Command::SUMMON(&m.args[0][], Some(&m.args[1][]), Some(&suffix[]))
Command::SUMMON(&m.args[0], Some(&m.args[1]), Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 1 {
Command::SUMMON(&m.args[0][], None, None)
Command::SUMMON(&m.args[0], None, None)
} else if m.args.len() == 2 {
Command::SUMMON(&m.args[0][], Some(&m.args[1][]), None)
Command::SUMMON(&m.args[0], Some(&m.args[1]), None)
} else if m.args.len() == 3 {
Command::SUMMON(&m.args[0][], Some(&m.args[1][]), Some(&m.args[2][]))
Command::SUMMON(&m.args[0], Some(&m.args[1]), Some(&m.args[2]))
} else {
return Err(invalid_input())
}
}
} else if let "USERS" = &m.command[] {
} else if let "USERS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::USERS(Some(&suffix[]))
Command::USERS(Some(&suffix))
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::USERS(Some(&m.args[0][]))
Command::USERS(Some(&m.args[0]))
}
}
} else if let "WALLOPS" = &m.command[] {
} else if let "WALLOPS" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::WALLOPS(&suffix[])
Command::WALLOPS(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::WALLOPS(&m.args[0][])
Command::WALLOPS(&m.args[0])
}
}
} else if let "USERHOST" = &m.command[] {
} else if let "USERHOST" = &m.command[..] {
if m.suffix.is_none() {
Command::USERHOST(m.args.iter().map(|s| &s[]).collect())
Command::USERHOST(m.args.iter().map(|s| &s[..]).collect())
} else {
return Err(invalid_input())
}
} else if let "ISON" = &m.command[] {
} else if let "ISON" = &m.command[..] {
if m.suffix.is_none() {
Command::USERHOST(m.args.iter().map(|s| &s[]).collect())
Command::USERHOST(m.args.iter().map(|s| &s[..]).collect())
} else {
return Err(invalid_input())
}
} else if let "SAJOIN" = &m.command[] {
} else if let "SAJOIN" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::SAJOIN(&m.args[0][], &suffix[])
Command::SAJOIN(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::SAJOIN(&m.args[0][], &m.args[1][])
Command::SAJOIN(&m.args[0], &m.args[1])
}
}
} else if let "SAMODE" = &m.command[] {
} else if let "SAMODE" = &m.command[..] {
match m.suffix {
Some(ref suffix) => if m.args.len() == 1 {
Command::SAMODE(&m.args[0][], &suffix[], None)
Command::SAMODE(&m.args[0], &suffix, None)
} else if m.args.len() == 2 {
Command::SAMODE(&m.args[0][], &m.args[1][], Some(&suffix[]))
Command::SAMODE(&m.args[0], &m.args[1], Some(&suffix))
} else {
return Err(invalid_input())
},
None => if m.args.len() == 2 {
Command::SAMODE(&m.args[0][], &m.args[1][], None)
Command::SAMODE(&m.args[0], &m.args[1], None)
} else if m.args.len() == 3 {
Command::SAMODE(&m.args[0][], &m.args[1][], Some(&m.args[2][]))
Command::SAMODE(&m.args[0], &m.args[1], Some(&m.args[2]))
} else {
return Err(invalid_input())
}
}
} else if let "SANICK" = &m.command[] {
} else if let "SANICK" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::SANICK(&m.args[0][], &suffix[])
Command::SANICK(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::SANICK(&m.args[0][], &m.args[1][])
Command::SANICK(&m.args[0], &m.args[1])
}
}
} else if let "SAPART" = &m.command[] {
} else if let "SAPART" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::SAPART(&m.args[0][], &suffix[])
Command::SAPART(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::SAPART(&m.args[0][], &m.args[1][])
Command::SAPART(&m.args[0], &m.args[1])
}
}
} else if let "SAQUIT" = &m.command[] {
} else if let "SAQUIT" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::SAQUIT(&m.args[0][], &suffix[])
Command::SAQUIT(&m.args[0], &suffix)
},
None => {
if m.args.len() != 2 { return Err(invalid_input()) }
Command::SAQUIT(&m.args[0][], &m.args[1][])
Command::SAQUIT(&m.args[0], &m.args[1])
}
}
} else if let "NICKSERV" = &m.command[] {
} else if let "NICKSERV" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::NICKSERV(&suffix[])
Command::NICKSERV(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::NICKSERV(&m.args[0][])
Command::NICKSERV(&m.args[0])
}
}
} else if let "CHANSERV" = &m.command[] {
} else if let "CHANSERV" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::CHANSERV(&suffix[])
Command::CHANSERV(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::CHANSERV(&m.args[0][])
Command::CHANSERV(&m.args[0])
}
}
} else if let "OPERSERV" = &m.command[] {
} else if let "OPERSERV" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::OPERSERV(&suffix[])
Command::OPERSERV(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::OPERSERV(&m.args[0][])
Command::OPERSERV(&m.args[0])
}
}
} else if let "BOTSERV" = &m.command[] {
} else if let "BOTSERV" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::BOTSERV(&suffix[])
Command::BOTSERV(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::BOTSERV(&m.args[0][])
Command::BOTSERV(&m.args[0])
}
}
} else if let "HOSTSERV" = &m.command[] {
} else if let "HOSTSERV" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::HOSTSERV(&suffix[])
Command::HOSTSERV(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::HOSTSERV(&m.args[0][])
Command::HOSTSERV(&m.args[0])
}
}
} else if let "MEMOSERV" = &m.command[] {
} else if let "MEMOSERV" = &m.command[..] {
match m.suffix {
Some(ref suffix) => {
if m.args.len() != 0 { return Err(invalid_input()) }
Command::MEMOSERV(&suffix[])
Command::MEMOSERV(&suffix)
},
None => {
if m.args.len() != 1 { return Err(invalid_input()) }
Command::MEMOSERV(&m.args[0][])
Command::MEMOSERV(&m.args[0])
}
}
} else if let "CAP" = &m.command[] {
} else if let "CAP" = &m.command[..] {
if m.args.len() != 1 { return Err(invalid_input()) }
if let Ok(cmd) = m.args[0].parse() {
match m.suffix {
Some(ref suffix) => Command::CAP(cmd, Some(&suffix[])),
Some(ref suffix) => Command::CAP(cmd, Some(&suffix)),
None => Command::CAP(cmd, None),
}
} else {

View file

@ -67,7 +67,7 @@ impl Config {
pub fn load(path: Path) -> IoResult<Config> {
let mut file = try!(File::open(&path));
let data = try!(file.read_to_string());
decode(&data[]).map_err(|e| IoError {
decode(&data[..]).map_err(|e| IoError {
kind: InvalidInput,
desc: "Failed to decode configuration file.",
detail: Some(e.description().to_owned()),
@ -90,21 +90,21 @@ impl Config {
/// This will panic if not specified.
#[stable]
pub fn nickname(&self) -> &str {
self.nickname.as_ref().map(|s| &s[]).unwrap()
self.nickname.as_ref().map(|s| &s[..]).unwrap()
}
/// Gets the bot's nickserv password specified in the configuration.
/// This defaults to an empty string when not specified.
#[stable]
pub fn nick_password(&self) -> &str {
self.nick_password.as_ref().map(|s| &s[]).unwrap_or("")
self.nick_password.as_ref().map(|s| &s[..]).unwrap_or("")
}
/// Gets the alternate nicknames specified in the configuration.
/// This defaults to an empty vector when not specified.
#[stable]
pub fn get_alternate_nicknames(&self) -> Vec<&str> {
self.alt_nicks.as_ref().map(|v| v.iter().map(|s| &s[]).collect()).unwrap_or(vec![])
self.alt_nicks.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
}
@ -112,21 +112,21 @@ impl Config {
/// This defaults to the user's nickname when not specified.
#[stable]
pub fn username(&self) -> &str {
self.username.as_ref().map(|s| &s[]).unwrap_or(self.nickname())
self.username.as_ref().map(|s| &s[..]).unwrap_or(self.nickname())
}
/// Gets the real name specified in the configuration.
/// This defaults to the user's nickname when not specified.
#[stable]
pub fn real_name(&self) -> &str {
self.realname.as_ref().map(|s| &s[]).unwrap_or(self.nickname())
self.realname.as_ref().map(|s| &s[..]).unwrap_or(self.nickname())
}
/// Gets the address of the server specified in the configuration.
/// This panics when not specified.
#[stable]
pub fn server(&self) -> &str {
self.server.as_ref().map(|s| &s[]).unwrap()
self.server.as_ref().map(|s| &s[..]).unwrap()
}
/// Gets the port of the server specified in the configuration.
@ -144,7 +144,7 @@ impl Config {
/// This defaults to a blank string when not specified.
#[stable]
pub fn password(&self) -> &str {
self.password.as_ref().map(|s| &s[]).unwrap_or("")
self.password.as_ref().map(|s| &s[..]).unwrap_or("")
}
/// Gets whether or not to use SSL with this connection.
@ -158,21 +158,21 @@ impl Config {
/// This defaults to UTF-8 when not specified.
#[stable]
pub fn encoding(&self) -> &str {
self.encoding.as_ref().map(|s| &s[]).unwrap_or("UTF-8")
self.encoding.as_ref().map(|s| &s[..]).unwrap_or("UTF-8")
}
/// Gets the channels to join upon connection.
/// This defaults to an empty vector if it's not specified.
#[stable]
pub fn channels(&self) -> Vec<&str> {
self.channels.as_ref().map(|v| v.iter().map(|s| &s[]).collect()).unwrap_or(vec![])
self.channels.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
}
/// Gets the user modes to set on connect specified in the configuration.
/// This defaults to an empty string when not specified.
#[unstable = "Feature is still relatively new."]
pub fn umodes(&self) -> &str {
self.umodes.as_ref().map(|s| &s[]).unwrap_or("")
self.umodes.as_ref().map(|s| &s[..]).unwrap_or("")
}
@ -180,7 +180,7 @@ impl Config {
/// This defaults to an empty string when not specified.
#[stable]
pub fn user_info(&self) -> &str {
self.user_info.as_ref().map(|s| &s[]).unwrap_or("")
self.user_info.as_ref().map(|s| &s[..]).unwrap_or("")
}
/// Looks up the specified string in the options map.
@ -188,7 +188,7 @@ impl Config {
/// This will also panic if used and there are no options.
#[stable]
pub fn get_option(&self, option: &str) -> &str {
self.options.as_ref().map(|o| &o[option.to_owned()][]).unwrap()
self.options.as_ref().map(|o| &o[option.to_owned()][..]).unwrap()
}
}

View file

@ -48,17 +48,17 @@ impl Message {
let mut ret = String::new();
if let Some(ref prefix) = self.prefix {
ret.push(':');
ret.push_str(&prefix[]);
ret.push_str(&prefix);
ret.push(' ');
}
ret.push_str(&self.command[]);
ret.push_str(&self.command);
for arg in self.args.iter() {
ret.push(' ');
ret.push_str(&arg[]);
ret.push_str(&arg);
}
if let Some(ref suffix) = self.suffix {
ret.push_str(" :");
ret.push_str(&suffix[]);
ret.push_str(&suffix);
}
ret.push_str("\r\n");
ret

View file

@ -45,7 +45,7 @@ impl User {
/// Gets the nickname of the user.
#[stable]
pub fn get_name(&self) -> &str {
&self.name[]
&self.name
}
/// Gets the user's highest access level.
@ -88,7 +88,7 @@ impl User {
/// Removes an access level from the list, and updates the highest level if necessary.
fn sub_access_level(&mut self, level: AccessLevel) {
if let Some(n) = self.access_levels[].position_elem(&level) {
if let Some(n) = self.access_levels[..].position_elem(&level) {
self.access_levels.swap_remove(n);
}
if level == self.highest_access_level() {

View file

@ -128,7 +128,7 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
if resp == Response::RPL_NAMREPLY {
if cfg!(not(feature = "nochanlists")) {
if let Some(users) = msg.suffix.clone() {
if let [_, _, ref chan] = &msg.args[] {
if let [_, _, ref chan] = &msg.args[..] {
for user in users.split_str(" ") {
if match self.chanlists.lock().unwrap().get_mut(chan) {
Some(vec) => { vec.push(User::new(user)); false },
@ -144,14 +144,14 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
} else if resp == Response::RPL_ENDOFMOTD || resp == Response::ERR_NOMOTD {
if self.config.nick_password() != "" {
self.send(NICKSERV(
&format!("IDENTIFY {}", self.config.nick_password())[]
&format!("IDENTIFY {}", self.config.nick_password())[..]
)).unwrap();
}
if self.config.umodes() != "" {
self.send(MODE(self.config.nickname(), self.config.umodes(), None)).unwrap();
}
for chan in self.config.channels().into_iter() {
self.send(JOIN(&chan[], None)).unwrap();
self.send(JOIN(&chan[..], None)).unwrap();
}
} else if resp == Response::ERR_NICKNAMEINUSE ||
resp == Response::ERR_ERRONEOUSNICKNAME {
@ -166,18 +166,18 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
}
return
}
if &msg.command[] == "PING" {
self.send(PONG(&msg.suffix.as_ref().unwrap()[], None)).unwrap();
if &msg.command[..] == "PING" {
self.send(PONG(&msg.suffix.as_ref().unwrap()[..], None)).unwrap();
} else if cfg!(not(feature = "nochanlists")) &&
(&msg.command[] == "JOIN" || &msg.command[] == "PART") {
(&msg.command[..] == "JOIN" || &msg.command[..] == "PART") {
let chan = match msg.suffix {
Some(ref suffix) => &suffix[],
None => &msg.args[0][],
Some(ref suffix) => &suffix[..],
None => &msg.args[0][..],
};
if let Some(vec) = self.chanlists.lock().unwrap().get_mut(&String::from_str(chan)) {
if let Some(ref src) = msg.prefix {
if let Some(i) = src.find('!') {
if &msg.command[] == "JOIN" {
if &msg.command[..] == "JOIN" {
vec.push(User::new(&src[..i]));
} else {
if let Some(n) = vec.as_slice().position_elem(&User::new(&src[..i])) {
@ -187,11 +187,11 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
}
}
}
} else if let ("MODE", [ref chan, ref mode, ref user]) = (&msg.command[], &msg.args[]) {
} else if let ("MODE", [ref chan, ref mode, ref user]) = (&msg.command[..], &msg.args[..]) {
if cfg!(not(feature = "nochanlists")) {
if let Some(vec) = self.chanlists.lock().unwrap().get_mut(chan) {
if let Some(n) = vec.as_slice().position_elem(&User::new(&user[])) {
vec[n].update_access_level(&mode[]);
if let Some(n) = vec.as_slice().position_elem(&User::new(&user[..])) {
vec[n].update_access_level(&mode[..]);
}
}
}
@ -204,11 +204,11 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
#[cfg(feature = "ctcp")]
fn handle_ctcp(&self, msg: &Message) {
let source = match msg.prefix {
Some(ref source) => source.find('!').map_or(&source[], |i| &source[..i]),
Some(ref source) => source.find('!').map_or(&source[..], |i| &source[..i]),
None => "",
};
if let ("PRIVMSG", [ref target]) = (&msg.command[], &msg.args[]) {
let resp = if target.starts_with("#") { &target[] } else { source };
if let ("PRIVMSG", [ref target]) = (&msg.command[..], &msg.args[..]) {
let resp = if target.starts_with("#") { &target[..] } else { source };
match msg.suffix {
Some(ref msg) if msg.starts_with("\u{001}") => {
let tokens: Vec<_> = {
@ -222,16 +222,16 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
match tokens[0] {
"FINGER" => self.send_ctcp(resp, &format!("FINGER :{} ({})",
self.config.real_name(),
self.config.username())[]),
self.config.username())),
"VERSION" => self.send_ctcp(resp, "VERSION irc:git:Rust"),
"SOURCE" => {
self.send_ctcp(resp, "SOURCE https://github.com/aatxe/irc");
self.send_ctcp(resp, "SOURCE");
},
"PING" => self.send_ctcp(resp, &format!("PING {}", tokens[1])[]),
"TIME" => self.send_ctcp(resp, &format!("TIME :{}", now().rfc822z())[]),
"PING" => self.send_ctcp(resp, &format!("PING {}", tokens[1])),
"TIME" => self.send_ctcp(resp, &format!("TIME :{}", now().rfc822z())),
"USERINFO" => self.send_ctcp(resp, &format!("USERINFO :{}",
self.config.user_info())[]),
self.config.user_info())),
_ => {}
}
},
@ -243,7 +243,7 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
/// Sends a CTCP-escaped message.
#[cfg(feature = "ctcp")]
fn send_ctcp(&self, target: &str, msg: &str) {
self.send(Command::NOTICE(target, &format!("\u{001}{}\u{001}", msg)[])).unwrap();
self.send(Command::NOTICE(target, &format!("\u{001}{}\u{001}", msg)[..])).unwrap();
}
/// Handles CTCP requests if the CTCP feature is enabled.
@ -338,9 +338,9 @@ mod test {
));
let mut messages = String::new();
for message in server.iter() {
messages.push_str(&message.unwrap().into_string()[]);
messages.push_str(&message.unwrap().into_string());
}
assert_eq!(&messages[], exp);
assert_eq!(&messages, exp);
}
#[test]
@ -352,7 +352,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PONG :irc.test.net\r\nJOIN #test\r\nJOIN #test2\r\n");
}
@ -369,7 +369,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"NICKSERV IDENTIFY password\r\nJOIN #test\r\nJOIN #test2\r\n");
}
@ -387,7 +387,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"MODE test +B\r\nJOIN #test\r\nJOIN #test2\r\n");
}
@ -400,7 +400,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[], "NICK :test2\r\n");
assert_eq!(&get_server_value(server)[..], "NICK :test2\r\n");
}
#[test]
@ -422,7 +422,7 @@ mod test {
NullReader, Vec::new()
));
assert!(server.send(PRIVMSG("#test", "Hi there!")).is_ok());
assert_eq!(&get_server_value(server)[], "PRIVMSG #test :Hi there!\r\n");
assert_eq!(&get_server_value(server)[..], "PRIVMSG #test :Hi there!\r\n");
}
#[cfg(not(feature = "nochanlists"))]
@ -503,7 +503,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[], "NOTICE test :\u{001}FINGER :test (test)\u{001}\
assert_eq!(&get_server_value(server)[..], "NOTICE test :\u{001}FINGER :test (test)\u{001}\
\r\n");
}
@ -517,7 +517,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[], "NOTICE test :\u{001}VERSION irc:git:Rust\u{001}\
assert_eq!(&get_server_value(server)[..], "NOTICE test :\u{001}VERSION irc:git:Rust\u{001}\
\r\n");
}
@ -531,7 +531,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"NOTICE test :\u{001}SOURCE https://github.com/aatxe/irc\u{001}\r\n\
NOTICE test :\u{001}SOURCE\u{001}\r\n");
}
@ -546,7 +546,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[], "NOTICE test :\u{001}PING test\u{001}\r\n");
assert_eq!(&get_server_value(server)[..], "NOTICE test :\u{001}PING test\u{001}\r\n");
}
#[test]
@ -574,7 +574,7 @@ mod test {
for message in server.iter() {
println!("{:?}", message);
}
assert_eq!(&get_server_value(server)[], "NOTICE test :\u{001}USERINFO :Testing.\u{001}\
assert_eq!(&get_server_value(server)[..], "NOTICE test :\u{001}USERINFO :Testing.\u{001}\
\r\n");
}
}

View file

@ -172,7 +172,7 @@ impl<'a, T: IrcReader, U: IrcWriter> Wrapper<'a, T, U> {
#[stable]
#[cfg(feature = "ctcp")]
pub fn send_ctcp(&self, target: &str, msg: &str) -> IoResult<()> {
self.send_privmsg(target, &format!("\u{001}{}\u{001}", msg)[])
self.send_privmsg(target, &format!("\u{001}{}\u{001}", msg)[..])
}
/// Sends an action command to the specified target.
@ -180,7 +180,7 @@ impl<'a, T: IrcReader, U: IrcWriter> Wrapper<'a, T, U> {
#[stable]
#[cfg(feature = "ctcp")]
pub fn send_action(&self, target: &str, msg: &str) -> IoResult<()> {
self.send_ctcp(target, &format!("ACTION {}", msg)[])
self.send_ctcp(target, &format!("ACTION {}", msg)[..])
}
/// Sends a finger request to the specified target.
@ -221,7 +221,7 @@ impl<'a, T: IrcReader, U: IrcWriter> Wrapper<'a, T, U> {
#[cfg(feature = "ctcp")]
pub fn send_ctcp_ping(&self, target: &str) -> IoResult<()> {
let time = get_time();
self.send_ctcp(target, &format!("PING {}.{}", time.sec, time.nsec)[])
self.send_ctcp(target, &format!("PING {}.{}", time.sec, time.nsec)[..])
}
/// Sends a time request to the specified target.
@ -251,7 +251,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.identify().unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"CAP REQ :multi-prefix\r\nCAP END\r\nNICK :test\r\nUSER test 0 * :test\r\n");
}
@ -266,7 +266,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.identify().unwrap();
}
assert_eq!(&get_server_value(server)[], "CAP REQ :multi-prefix\r\nCAP END\r\n\
assert_eq!(&get_server_value(server)[..], "CAP REQ :multi-prefix\r\nCAP END\r\n\
PASS :password\r\nNICK :test\r\nUSER test 0 * :test\r\n");
}
@ -278,7 +278,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_pong("irc.test.net").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PONG :irc.test.net\r\n");
}
@ -290,7 +290,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_join("#test,#test2,#test3").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"JOIN #test,#test2,#test3\r\n");
}
@ -302,7 +302,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_oper("test", "test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"OPER test :test\r\n");
}
@ -314,7 +314,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_privmsg("#test", "Hi, everybody!").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG #test :Hi, everybody!\r\n");
}
@ -326,7 +326,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_notice("#test", "Hi, everybody!").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"NOTICE #test :Hi, everybody!\r\n");
}
@ -338,7 +338,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_topic("#test", "").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"TOPIC #test\r\n");
}
@ -350,7 +350,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_topic("#test", "Testing stuff.").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"TOPIC #test :Testing stuff.\r\n");
}
@ -362,7 +362,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_kill("test", "Testing kills.").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"KILL test :Testing kills.\r\n");
}
@ -374,7 +374,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_kick("#test", "test", "").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"KICK #test test\r\n");
}
@ -386,7 +386,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_kick("#test", "test", "Testing kicks.").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"KICK #test test :Testing kicks.\r\n");
}
@ -398,7 +398,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_mode("#test", "+i", "").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"MODE #test +i\r\n");
}
@ -410,7 +410,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_mode("#test", "+o", "test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"MODE #test +o test\r\n");
}
@ -422,7 +422,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_samode("#test", "+i", "").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"SAMODE #test +i\r\n");
}
@ -434,7 +434,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_samode("#test", "+o", "test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"SAMODE #test +o test\r\n");
}
@ -446,7 +446,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_sanick("test", "test2").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"SANICK test test2\r\n");
}
@ -458,7 +458,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_invite("test", "#test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"INVITE test #test\r\n");
}
@ -471,7 +471,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_ctcp("test", "MESSAGE").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}MESSAGE\u{001}\r\n");
}
@ -484,7 +484,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_action("test", "tests.").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}ACTION tests.\u{001}\r\n");
}
@ -497,7 +497,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_finger("test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}FINGER\u{001}\r\n");
}
@ -510,7 +510,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_version("test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}VERSION\u{001}\r\n");
}
@ -523,7 +523,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_source("test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}SOURCE\u{001}\r\n");
}
@ -536,7 +536,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_user_info("test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}USERINFO\u{001}\r\n");
}
@ -564,7 +564,7 @@ mod test {
let wrapper = Wrapper::new(&server);
wrapper.send_time("test").unwrap();
}
assert_eq!(&get_server_value(server)[],
assert_eq!(&get_server_value(server)[..],
"PRIVMSG test :\u{001}TIME\u{001}\r\n");
}
}

View file

@ -4,7 +4,7 @@
#![unstable]
#![warn(missing_docs)]
#![feature(collections, core, io, path)]
#![feature(collections, core, io, old_io, old_path)]
#[cfg(feature = "ctcp")] extern crate time;
#[cfg(feature = "encode")] extern crate encoding;
extern crate "rustc-serialize" as rustc_serialize;