Cleaned up code, and more warning fixes.

This commit is contained in:
Aaron Weiss 2015-02-21 10:18:53 -05:00
parent dd4635d39f
commit 76e7aea8e7
7 changed files with 10 additions and 15 deletions

View file

@ -1,9 +1,8 @@
#![feature(slicing_syntax, std_misc)]
extern crate irc;
use std::default::Default;
use std::sync::Arc;
use std::thread::Thread;
use std::thread::spawn;
use irc::client::data::{Command, Config};
use irc::client::server::{IrcServer, Server};
use irc::client::server::utils::Wrapper;
@ -18,7 +17,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::scoped(move || {
let _ = spawn(move || {
let server = Wrapper::new(&*irc_server);
server.identify().unwrap();
loop {

View file

@ -1,9 +1,8 @@
#![feature(slicing_syntax, std_misc)]
extern crate irc;
use std::default::Default;
use std::sync::Arc;
use std::thread::Thread;
use std::thread::spawn;
use irc::client::data::config::Config;
use irc::client::server::{IrcServer, Server};
use irc::client::server::utils::Wrapper;
@ -21,7 +20,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::scoped(move || {
let _ = spawn(move || {
for msg in server.iter() {
print!("{}", msg.unwrap().into_string());
}

View file

@ -1,4 +1,3 @@
#![feature(slicing_syntax)]
extern crate irc;
use std::default::Default;
@ -21,7 +20,7 @@ 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();

View file

@ -1,4 +1,3 @@
#![feature(slicing_syntax)]
extern crate irc;
use std::default::Default;
@ -22,7 +21,7 @@ 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();

View file

@ -1,10 +1,10 @@
#![feature(io, slicing_syntax, std_misc)]
#![feature(old_io, std_misc)]
extern crate irc;
use std::default::Default;
use std::old_io::timer::sleep;
use std::sync::Arc;
use std::thread::Thread;
use std::thread::spawn;
use std::time::duration::Duration;
use irc::client::data::config::Config;
use irc::client::server::{IrcServer, Server};
@ -23,7 +23,7 @@ fn main() {
let server = Wrapper::new(&*irc_server2);
server.identify().unwrap();
// Let's set up a loop that just prints the messages.
Thread::spawn(move || {
spawn(move || {
irc_server.iter().map(|m| print!("{}", m.unwrap().into_string())).count();
});
loop {

View file

@ -175,7 +175,6 @@ impl Config {
self.umodes.as_ref().map(|s| &s[..]).unwrap_or("")
}
/// Gets the string to be sent in response to CTCP USERINFO requests.
/// This defaults to an empty string when not specified.
#[stable]

View file

@ -340,7 +340,7 @@ mod test {
for message in server.iter() {
messages.push_str(&message.unwrap().into_string());
}
assert_eq!(&messages, exp);
assert_eq!(&messages[..], exp);
}
#[test]