diff --git a/examples/autoreconnect.rs b/examples/autoreconnect.rs index 9c4fc5f..8a852d6 100644 --- a/examples/autoreconnect.rs +++ b/examples/autoreconnect.rs @@ -1,3 +1,4 @@ +#![allow(unstable)] #![feature(slicing_syntax)] extern crate irc; @@ -18,7 +19,7 @@ fn main() { let irc_server = Arc::new(IrcServer::from_config(config).unwrap()); irc_server.conn().set_keepalive(Some(5)).unwrap(); // The wrapper provides us with methods like send_privmsg(...) and identify(...) - let _ = Thread::spawn(move || { + let _ = Thread::scoped(move || { let server = Wrapper::new(&*irc_server); server.identify().unwrap(); loop { diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index 4f88b69..3a4e820 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -1,3 +1,4 @@ +#![allow(unstable)] #![feature(slicing_syntax)] extern crate irc; @@ -21,7 +22,7 @@ fn main() { server.identify().unwrap(); let server = irc_server.clone(); // We won't use a wrapper here because we don't need the added functionality. - let _ = Thread::spawn(move || { + let _ = Thread::scoped(move || { for msg in server.iter() { print!("{}", msg.unwrap().into_string()); } diff --git a/examples/simple.rs b/examples/simple.rs index 6dc1cc3..8eb2174 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,3 +1,4 @@ +#![allow(unstable)] #![feature(slicing_syntax)] extern crate irc; @@ -21,10 +22,10 @@ fn main() { for message in server.iter() { let message = message.unwrap(); // We'll just panic if there's an error. print!("{}", message.into_string()); - if message.command[] == "PRIVMSG" { + if &message.command[] == "PRIVMSG" { if let Some(msg) = message.suffix { if msg.contains("pickles") { - server.send_privmsg(message.args[0][], "Hi!").unwrap(); + server.send_privmsg(&message.args[0][], "Hi!").unwrap(); } } } diff --git a/examples/simple_ssl.rs b/examples/simple_ssl.rs index 2f66196..7786bea 100644 --- a/examples/simple_ssl.rs +++ b/examples/simple_ssl.rs @@ -1,3 +1,4 @@ +#![allow(unstable)] #![feature(slicing_syntax)] extern crate irc; @@ -22,10 +23,10 @@ fn main() { for message in server.iter() { let message = message.unwrap(); // We'll just panic if there's an error. print!("{}", message.into_string()); - if message.command[] == "PRIVMSG" { + if &message.command[] == "PRIVMSG" { if let Some(msg) = message.suffix { if msg.contains("pickles") { - server.send_privmsg(message.args[0][], "Hi!").unwrap(); + server.send_privmsg(&message.args[0][], "Hi!").unwrap(); } } } diff --git a/examples/tweeter.rs b/examples/tweeter.rs index b64bdd5..08408bd 100644 --- a/examples/tweeter.rs +++ b/examples/tweeter.rs @@ -1,4 +1,5 @@ #![feature(slicing_syntax)] +#![allow(unstable)] extern crate irc; use std::default::Default; @@ -25,7 +26,7 @@ fn main() { // Let's set up a loop that just prints the messages. Thread::spawn(move || { irc_server.iter().map(|m| print!("{}", m.unwrap().into_string())).count(); - }).detach(); + }); loop { server.send_privmsg("#vana", "TWEET TWEET").unwrap(); sleep(Duration::seconds(10)) diff --git a/src/conn.rs b/src/conn.rs index 4f3bb9d..906e320 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -1,8 +1,9 @@ //! Thread-safe connections on IrcStreams. #![experimental] -use std::sync::{Mutex, MutexGuard}; +use std::error::Error; use std::io::{BufferedReader, BufferedWriter, IoResult, TcpStream}; #[cfg(any(feature = "encode", feature = "ssl"))] use std::io::{IoError, IoErrorKind}; +use std::sync::{Mutex, MutexGuard}; #[cfg(feature = "encode")] use encoding::{DecoderTrap, EncoderTrap, Encoding}; #[cfg(feature = "encode")] use encoding::label::encoding_from_whatwg_label; use data::kinds::{IrcReader, IrcWriter}; @@ -33,7 +34,7 @@ impl Connection, BufferedWriter> { /// connects to the specified server and returns a reader-writer pair. fn connect_internal(host: &str, port: u16) -> IoResult { - 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)))) } @@ -49,7 +50,7 @@ impl Connection, BufferedWriter> { /// 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 { - 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())), @@ -81,7 +82,7 @@ impl Connection, BufferedWriter> { /// Sets the keepalive for the network stream. #[experimental] - pub fn set_keepalive(&self, delay_in_seconds: Option) -> IoResult<()> { + pub fn set_keepalive(&self, delay_in_seconds: Option) -> IoResult<()> { self.mod_stream(|tcp| tcp.set_keepalive(delay_in_seconds)) } @@ -94,9 +95,9 @@ impl Connection, BufferedWriter> { /// Modifies the internal TcpStream using a function. fn mod_stream(&self, f: F) -> IoResult<()> where F: FnOnce(&mut TcpStream) -> IoResult<()> { match self.reader.lock().unwrap().get_mut() { - &NetStream::UnsecuredTcpStream(ref mut tcp) => f(tcp), + &mut NetStream::UnsecuredTcpStream(ref mut tcp) => f(tcp), #[cfg(feature = "ssl")] - &NetStream::SslTcpStream(ref mut ssl) => f(ssl.get_mut()), + &mut NetStream::SslTcpStream(ref mut ssl) => f(ssl.get_mut()), } } } @@ -114,7 +115,7 @@ impl Connection { /// Sends a Message over this connection. #[experimental] #[cfg(feature = "encode")] - pub fn send(&self, to_msg: T, encoding: &str) -> IoResult<()> { + pub fn send(&self, to_msg: M, encoding: &str) -> IoResult<()> { let encoding = match encoding_from_whatwg_label(encoding) { Some(enc) => enc, None => return Err(IoError { @@ -124,7 +125,7 @@ impl Connection { }) }; 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, @@ -133,7 +134,7 @@ impl Connection { }) }; let mut writer = self.writer.lock().unwrap(); - try!(writer.write(data[])); + try!(writer.write(&data[])); writer.flush() } @@ -159,7 +160,7 @@ impl Connection { }) }; 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, @@ -198,7 +199,7 @@ fn ssl_to_io(res: Result) -> IoResult { Err(e) => Err(IoError { kind: IoErrorKind::OtherIoError, desc: "An SSL error occurred.", - detail: Some(format!("{}", e)), + detail: e.detail(), }), } } @@ -215,11 +216,11 @@ pub enum NetStream { } impl Reader for NetStream { - fn read(&mut self, buf: &mut [u8]) -> IoResult { + fn read(&mut self, buf: &mut [u8]) -> IoResult { match self { - &NetStream::UnsecuredTcpStream(ref mut stream) => stream.read(buf), + &mut NetStream::UnsecuredTcpStream(ref mut stream) => stream.read(buf), #[cfg(feature = "ssl")] - &NetStream::SslTcpStream(ref mut stream) => stream.read(buf), + &mut NetStream::SslTcpStream(ref mut stream) => stream.read(buf), } } } @@ -227,9 +228,9 @@ impl Reader for NetStream { impl Writer for NetStream { fn write(&mut self, buf: &[u8]) -> IoResult<()> { match self { - &NetStream::UnsecuredTcpStream(ref mut stream) => stream.write(buf), + &mut NetStream::UnsecuredTcpStream(ref mut stream) => stream.write(buf), #[cfg(feature = "ssl")] - &NetStream::SslTcpStream(ref mut stream) => stream.write(buf), + &mut NetStream::SslTcpStream(ref mut stream) => stream.write(buf), } } } @@ -251,7 +252,7 @@ mod test { Message::new(None, "PRIVMSG", Some(vec!["test"]), Some("Testing!")) ).is_ok()); let data = String::from_utf8(conn.writer().get_ref().to_vec()).unwrap(); - assert_eq!(data[], "PRIVMSG test :Testing!\r\n"); + assert_eq!(&data[], "PRIVMSG test :Testing!\r\n"); } #[test] @@ -261,7 +262,7 @@ mod test { let conn = Connection::new(NullReader, MemWriter::new()); assert!(conn.send(exp).is_ok()); let data = String::from_utf8(conn.writer().get_ref().to_vec()).unwrap(); - assert_eq!(data[], exp); + assert_eq!(&data[], exp); } #[test] @@ -272,7 +273,7 @@ mod test { Message::new(None, "PRIVMSG", Some(vec!["test"]), Some("€ŠšŽžŒœŸ")), "UTF-8" ).is_ok()); let data = UTF_8.decode(conn.writer().get_ref(), DecoderTrap::Strict).unwrap(); - assert_eq!(data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); + assert_eq!(&data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); } #[test] @@ -282,7 +283,7 @@ mod test { let conn = Connection::new(NullReader, MemWriter::new()); assert!(conn.send(exp, "UTF-8").is_ok()); let data = UTF_8.decode(conn.writer().get_ref(), DecoderTrap::Strict).unwrap(); - assert_eq!(data[], exp); + assert_eq!(&data[], exp); } #[test] @@ -293,7 +294,7 @@ mod test { Message::new(None, "PRIVMSG", Some(vec!["test"]), Some("€ŠšŽžŒœŸ")), "l9" ).is_ok()); let data = ISO_8859_15.decode(conn.writer().get_ref(), DecoderTrap::Strict).unwrap(); - assert_eq!(data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); + assert_eq!(&data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); } #[test] @@ -303,7 +304,7 @@ mod test { let conn = Connection::new(NullReader, MemWriter::new()); assert!(conn.send(exp, "l9").is_ok()); let data = ISO_8859_15.decode(conn.writer().get_ref(), DecoderTrap::Strict).unwrap(); - assert_eq!(data[], exp); + assert_eq!(&data[], exp); } #[test] @@ -312,7 +313,7 @@ mod test { let conn = Connection::new( MemReader::new("PRIVMSG test :Testing!\r\n".as_bytes().to_vec()), NullWriter ); - assert_eq!(conn.recv().unwrap()[], "PRIVMSG test :Testing!\r\n"); + assert_eq!(&conn.recv().unwrap()[], "PRIVMSG test :Testing!\r\n"); } #[test] @@ -321,7 +322,7 @@ mod test { let conn = Connection::new( MemReader::new(b"PRIVMSG test :Testing!\r\n".to_vec()), NullWriter ); - assert_eq!(conn.recv("UTF-8").unwrap()[], "PRIVMSG test :Testing!\r\n"); + assert_eq!(&conn.recv("UTF-8").unwrap()[], "PRIVMSG test :Testing!\r\n"); } #[test] @@ -336,6 +337,6 @@ mod test { vec }), NullWriter ); - assert_eq!(conn.recv("l9").unwrap()[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); + assert_eq!(&conn.recv("l9").unwrap()[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); } } diff --git a/src/data/command.rs b/src/data/command.rs index 0835a00..f7a0135 100644 --- a/src/data/command.rs +++ b/src/data/command.rs @@ -161,8 +161,8 @@ impl<'a> ToMessage for Command<'a> { Command::OPER(u, p) => Message::new(None, "OPER", Some(vec![u]), Some(p)), Command::MODE(t, m, Some(p)) => Message::new(None, "MODE", Some(vec![t, m, p]), None), Command::MODE(t, m, None) => Message::new(None, "MODE", Some(vec![t, m]), None), - Command::SERVICE(n, r, d, t, re, i) => Message::new(None, "SERVICE", - Some(vec![n, r, d, t, re]), + Command::SERVICE(n, r, d, t, re, i) => Message::new(None, "SERVICE", + Some(vec![n, r, d, t, re]), Some(i)), Command::QUIT(Some(m)) => Message::new(None, "QUIT", None, Some(m)), Command::QUIT(None) => Message::new(None, "QUIT", None, None), @@ -268,277 +268,277 @@ impl<'a> Command<'a> { /// Converts a Message into a Command. #[stable] pub fn from_message(m: &'a Message) -> IoResult> { - 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()) }, @@ -548,396 +548,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 Some(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 { diff --git a/src/data/config.rs b/src/data/config.rs index e6447a6..b7cd139 100644 --- a/src/data/config.rs +++ b/src/data/config.rs @@ -2,6 +2,7 @@ #![stable] use std::borrow::ToOwned; use std::collections::HashMap; +use std::error::Error; use std::io::fs::File; use std::io::{InvalidInput, IoError, IoResult}; use rustc_serialize::json::decode; @@ -48,10 +49,10 @@ impl Config { pub fn load(path: Path) -> IoResult { 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.to_string()), + detail: e.detail(), }) } @@ -71,21 +72,21 @@ impl Config { /// This will panic if not specified. #[experimental] 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. #[experimental] 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. #[experimental] 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![]) } @@ -93,21 +94,21 @@ impl Config { /// This defaults to the user's nickname when not specified. #[experimental] 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. #[experimental] 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. #[experimental] 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. @@ -125,7 +126,7 @@ impl Config { /// This defaults to a blank string when not specified. #[experimental] 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. @@ -139,21 +140,21 @@ impl Config { /// This defaults to UTF-8 when not specified. #[experimental] 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. #[experimental] 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 string to be sent in response to CTCP USERINFO requests. /// This defaults to an empty string when not specified. #[experimental] 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. @@ -161,7 +162,7 @@ impl Config { /// This will also panic if used and there are no options. #[experimental] 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() } } diff --git a/src/data/message.rs b/src/data/message.rs index 995920c..5b0af79 100644 --- a/src/data/message.rs +++ b/src/data/message.rs @@ -34,7 +34,7 @@ impl Message { /// Gets the nickname of the message source, if it exists. #[experimental] pub fn get_source_nickname(&self) -> Option<&str> { - self.prefix.as_ref().and_then(|s| s.find('!').map(|i| s[..i])) + self.prefix.as_ref().and_then(|s| s.find('!').map(|i| &s[..i])) } /// Converts a Message into a String according to the IRC protocol. @@ -43,17 +43,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 @@ -71,27 +71,27 @@ impl FromStr for Message { let mut state = s.clone(); if s.len() == 0 { return None } let prefix = if state.starts_with(":") { - let prefix = state.find(' ').map(|i| state[1..i]); - state = state.find(' ').map_or("", |i| state[i+1..]); + let prefix = state.find(' ').map(|i| &state[1..i]); + state = state.find(' ').map_or("", |i| &state[i+1..]); prefix } else { None }; let suffix = if state.contains(":") { - let suffix = state.find(':').map(|i| state[i+1..state.len()-2]); - state = state.find(':').map_or("", |i| state[..i]); + let suffix = state.find(':').map(|i| &state[i+1..state.len()-2]); + state = state.find(':').map_or("", |i| &state[..i]); suffix } else { None }; - let command = match state.find(' ').map(|i| state[..i]) { + let command = match state.find(' ').map(|i| &state[..i]) { Some(cmd) => { - state = state.find(' ').map_or("", |i| state[i+1..]); + state = state.find(' ').map_or("", |i| &state[i+1..]); cmd } _ => return None }; - if suffix.is_none() { state = state[..state.len() - 2] } + if suffix.is_none() { state = &state[..state.len() - 2] } let args: Vec<_> = state.splitn(14, ' ').filter(|s| s.len() != 0).collect(); Some(Message::new(prefix, command, if args.len() > 0 { Some(args) } else { None }, suffix)) } @@ -143,14 +143,14 @@ mod test { args: vec![format!("test")], suffix: Some(format!("Testing!")), }; - assert_eq!(message.into_string()[], "PRIVMSG test :Testing!\r\n"); + assert_eq!(&message.into_string()[], "PRIVMSG test :Testing!\r\n"); let message = Message { prefix: Some(format!("test!test@test")), command: format!("PRIVMSG"), args: vec![format!("test")], suffix: Some(format!("Still testing!")), }; - assert_eq!(message.into_string()[], ":test!test@test PRIVMSG test :Still testing!\r\n"); + assert_eq!(&message.into_string()[], ":test!test@test PRIVMSG test :Still testing!\r\n"); } #[test] diff --git a/src/data/response.rs b/src/data/response.rs index 39d21ff..940e31c 100644 --- a/src/data/response.rs +++ b/src/data/response.rs @@ -8,7 +8,7 @@ use data::message::Message; /// List of all server responses as defined in [RFC 2812](http://tools.ietf.org/html/rfc2812). /// All commands are documented with their expected form from the RFC. #[derive(Copy, Show, PartialEq, FromPrimitive)] -#[repr(uint)] +#[repr(u16)] #[unstable] pub enum Response { // Expected replies @@ -303,14 +303,14 @@ impl Response { /// Determines whether or not this response is an error response. #[stable] pub fn is_error(&self) -> bool { - *self as uint >= 400 + *self as u16 >= 400 } } impl FromStr for Response { fn from_str(s: &str) -> Option { if let Some(respcode) = s.parse() { - FromPrimitive::from_uint(respcode) + FromPrimitive::from_u16(respcode) } else { None } diff --git a/src/data/user.rs b/src/data/user.rs index 704402f..6f2f08a 100644 --- a/src/data/user.rs +++ b/src/data/user.rs @@ -44,7 +44,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. @@ -194,7 +194,7 @@ impl<'a> Iterator for AccessLevelIterator<'a> { fn next(&mut self) -> Option { let ret = self.value.parse(); if self.value.len() > 0 { - self.value = self.value[1..]; + self.value = &self.value[1..]; } ret } diff --git a/src/lib.rs b/src/lib.rs index 0efc393..550a49a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ #![crate_name = "irc"] #![crate_type = "lib"] #![unstable] +#![allow(unstable)] #![warn(missing_docs)] #![feature(slicing_syntax)] diff --git a/src/server/mod.rs b/src/server/mod.rs index 3eb50d7..27fe84b 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -35,7 +35,7 @@ pub struct IrcServer { /// A thread-safe map of channels to the list of users in them. chanlists: Mutex>>, /// A thread-safe index to track the current alternative nickname being used. - alt_nick_index: RwLock, + alt_nick_index: RwLock, } /// An IrcServer over a buffered NetStream. @@ -59,7 +59,7 @@ impl IrcServer, BufferedWriter> { Connection::connect(config.server(), config.port()) }); Ok(IrcServer { config: config, conn: conn, chanlists: Mutex::new(HashMap::new()), - alt_nick_index: RwLock::new(0u) }) + alt_nick_index: RwLock::new(0) }) } /// Reconnects to the IRC server. @@ -98,7 +98,7 @@ impl IrcServer { #[experimental] pub fn from_connection(config: Config, conn: Connection) -> IrcServer { IrcServer { conn: conn, config: config, chanlists: Mutex::new(HashMap::new()), - alt_nick_index: RwLock::new(0u) } + alt_nick_index: RwLock::new(0) } } /// Gets a reference to the IRC server's connection. @@ -113,7 +113,7 @@ impl IrcServer { if let Some(resp) = Response::from_message(msg) { if resp == Response::RPL_NAMREPLY { 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 }, @@ -128,11 +128,11 @@ impl IrcServer { } 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(); } 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 { @@ -147,30 +147,30 @@ impl IrcServer { } return } - if msg.command[] == "PING" { - self.send(PONG(msg.suffix.as_ref().unwrap()[], None)).unwrap(); - } else if msg.command[] == "JOIN" || msg.command[] == "PART" { + if &msg.command[] == "PING" { + self.send(PONG(&msg.suffix.as_ref().unwrap()[], None)).unwrap(); + } else if &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" { - vec.push(User::new(src[..i])); + if &msg.command[] == "JOIN" { + vec.push(User::new(&src[..i])); } else { - if let Some(n) = vec.as_slice().position_elem(&User::new(src[..i])) { + if let Some(n) = vec.as_slice().position_elem(&User::new(&src[..i])) { vec.swap_remove(n); } } } } } - } 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 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[]); } } } else { @@ -183,11 +183,11 @@ impl IrcServer { #[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<_> = { @@ -199,18 +199,18 @@ impl IrcServer { msg[1..end].split_str(" ").collect() }; match tokens[0] { - "FINGER" => self.send_ctcp(resp, format!("FINGER :{} ({})", - self.config.real_name(), - self.config.username())[]), + "FINGER" => self.send_ctcp(resp, &format!("FINGER :{} ({})", + self.config.real_name(), + 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())[]), - "USERINFO" => self.send_ctcp(resp, format!("USERINFO :{}", - self.config.user_info())[]), + "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())[]), _ => {} } }, @@ -223,7 +223,7 @@ impl IrcServer { #[experimental] #[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. @@ -319,9 +319,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] @@ -331,9 +331,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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"); } @@ -348,9 +348,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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"); } @@ -361,9 +361,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } - assert_eq!(get_server_value(server)[], "NICK :test2\r\n"); + assert_eq!(&get_server_value(server)[], "NICK :test2\r\n"); } #[test] @@ -375,7 +375,7 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } } @@ -385,7 +385,7 @@ mod test { NullReader, MemWriter::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"); } #[test] @@ -395,7 +395,7 @@ mod test { MemReader::new(value.as_bytes().to_vec()), NullWriter )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } assert_eq!(server.list_users("#test").unwrap(), vec![User::new("test"), User::new("~owner"), User::new("&admin")]) @@ -409,7 +409,7 @@ mod test { MemReader::new(value.as_bytes().to_vec()), NullWriter )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } assert_eq!(server.list_users("#test").unwrap(), vec![User::new("test"), User::new("~owner"), User::new("&admin"), User::new("test2")]) @@ -423,7 +423,7 @@ mod test { MemReader::new(value.as_bytes().to_vec()), NullWriter )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } assert_eq!(server.list_users("#test").unwrap(), vec![User::new("test"), User::new("&admin")]) @@ -437,7 +437,7 @@ mod test { MemReader::new(value.as_bytes().to_vec()), NullWriter )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } assert_eq!(server.list_users("#test").unwrap(), vec![User::new("@test"), User::new("~owner"), User::new("&admin")]); @@ -460,9 +460,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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"); } @@ -474,9 +474,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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"); } @@ -488,9 +488,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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"); } @@ -503,9 +503,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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] @@ -516,7 +516,7 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + println!("{:?}", message); } let val = get_server_value(server); assert!(val.starts_with("NOTICE test :\u{001}TIME :")); @@ -531,9 +531,9 @@ mod test { MemReader::new(value.as_bytes().to_vec()), MemWriter::new() )); for message in server.iter() { - println!("{}", message); + 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"); } } diff --git a/src/server/utils.rs b/src/server/utils.rs index 7772acf..d512787 100644 --- a/src/server/utils.rs +++ b/src/server/utils.rs @@ -171,7 +171,7 @@ impl<'a, T: IrcReader, U: IrcWriter> Wrapper<'a, T, U> { #[experimental] #[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. @@ -179,7 +179,7 @@ impl<'a, T: IrcReader, U: IrcWriter> Wrapper<'a, T, U> { #[experimental] #[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. @@ -220,7 +220,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"); } @@ -270,7 +270,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"); } @@ -282,7 +282,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"); } @@ -294,7 +294,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"); } @@ -306,7 +306,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"); } @@ -318,7 +318,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"); } @@ -330,7 +330,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"); } @@ -342,7 +342,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"); } @@ -354,7 +354,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"); } @@ -366,7 +366,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"); } @@ -378,7 +378,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"); } @@ -390,7 +390,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"); } @@ -402,7 +402,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"); } @@ -414,7 +414,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"); } @@ -426,7 +426,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"); } @@ -438,7 +438,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"); } @@ -450,7 +450,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"); } @@ -462,7 +462,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"); } @@ -475,7 +475,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"); } @@ -488,7 +488,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"); } @@ -501,7 +501,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"); } @@ -514,7 +514,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"); } @@ -527,7 +527,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"); } @@ -540,7 +540,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"); } @@ -568,7 +568,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"); } }