From ce4ab4d6a395bbce37531225d506552d6a910f3f Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Thu, 25 Dec 2014 11:39:05 +0000 Subject: Added unwrap calls around ident regex matches --- src/ident.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ident.rs b/src/ident.rs index 069e186..3089af4 100644 --- a/src/ident.rs +++ b/src/ident.rs @@ -16,9 +16,9 @@ impl Ident { None => return None }; Some(Ident { - nickname: c.at(1).into_string(), - user: c.at(2).into_string(), - host: c.at(3).into_string() + nickname: c.at(1).unwrap_or("").into_string(), + user: c.at(2).unwrap_or("").into_string(), + host: c.at(3).unwrap_or("").into_string() }) } } -- cgit v1.2.3 From 7181a9824cb7bda6e10f83f0a4d11e3fd493dcbf Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Thu, 25 Dec 2014 16:54:29 +0000 Subject: Fixed casting of function pointers --- src/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server.rs b/src/server.rs index 343cdee..7504658 100644 --- a/src/server.rs +++ b/src/server.rs @@ -30,7 +30,7 @@ impl Server { stream: Arc::new(Mutex::new(None)), events: { let mut c = Callback::new(); - c.register(&Server::handle_event); + c.register(&(Server::handle_event as fn((Server,Event)))); Arc::new(Mutex::new(c)) } } -- cgit v1.2.3 From 8d42ad9822e7e4b9e595bb2bd587a5da0db8ce9a Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Thu, 25 Dec 2014 18:33:49 +0000 Subject: Changed unwrap_or to unwrap because we want the program to fail instead of use emptystring if ident can't be unwrapped --- src/ident.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ident.rs b/src/ident.rs index 3089af4..19756ca 100644 --- a/src/ident.rs +++ b/src/ident.rs @@ -16,9 +16,9 @@ impl Ident { None => return None }; Some(Ident { - nickname: c.at(1).unwrap_or("").into_string(), - user: c.at(2).unwrap_or("").into_string(), - host: c.at(3).unwrap_or("").into_string() + nickname: c.at(1).unwrap().into_string(), + user: c.at(2).unwrap().into_string(), + host: c.at(3).unwrap().into_string() }) } } -- cgit v1.2.3 From 26a8e0c20cc1a300f8d03e152c9910839ce1cd53 Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Fri, 26 Dec 2014 13:28:56 +0000 Subject: Put examples back to how they were before and removed some into_string deprecated calls --- src/ident.rs | 7 ++++--- src/server.rs | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ident.rs b/src/ident.rs index 19756ca..6a01d12 100644 --- a/src/ident.rs +++ b/src/ident.rs @@ -1,4 +1,5 @@ use regex::Regex; +use std::borrow::ToOwned; static PATTERN: Regex = regex!(":(.*)!(.*)@(.*)"); @@ -16,9 +17,9 @@ impl Ident { None => return None }; Some(Ident { - nickname: c.at(1).unwrap().into_string(), - user: c.at(2).unwrap().into_string(), - host: c.at(3).unwrap().into_string() + nickname: c.at(1).unwrap().to_owned(), + user: c.at(2).unwrap().to_owned(), + host: c.at(3).unwrap().to_owned() }) } } diff --git a/src/server.rs b/src/server.rs index 7504658..309ecfb 100644 --- a/src/server.rs +++ b/src/server.rs @@ -7,6 +7,8 @@ use std::io::{ use std::sync::Arc; use std::sync::Mutex; +use std::borrow::ToOwned; + use callback::Callback; use event; use event::Event; @@ -126,8 +128,8 @@ impl Server { let cmd = parts.remove(0).unwrap(); let event = Event { - prefix: prefix.into_string(), - command: cmd.into_string(), + prefix: prefix.to_owned(), + command: cmd.to_owned(), content: parts.iter().map(|p| p.into_string()).collect() }; -- cgit v1.2.3 From 2ebcb68cd4c88891f42da1e5c1c29fefea947f23 Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Fri, 26 Dec 2014 13:47:21 +0000 Subject: No more warnings about deprecation! --- src/event.rs | 4 +++- src/server.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/event.rs b/src/event.rs index aef34f9..b8e9743 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1,5 +1,7 @@ use ident::Ident; +use std::borrow::ToOwned; + #[deriving(Clone)] pub struct Event { pub prefix: String, @@ -17,7 +19,7 @@ pub const PRIVMSG: &'static str = "PRIVMSG"; fn join(v: Vec, from: uint) -> String { let mut msg = if v[from].chars().next().unwrap() == ':' { - v[from][][1..].into_string() + v[from][][1..].to_owned() } else { v[from].clone() }; for m in v.iter().skip(from + 1) { msg.push_str(" "); diff --git a/src/server.rs b/src/server.rs index 309ecfb..4c4479a 100644 --- a/src/server.rs +++ b/src/server.rs @@ -130,7 +130,7 @@ impl Server { let event = Event { prefix: prefix.to_owned(), command: cmd.to_owned(), - content: parts.iter().map(|p| p.into_string()).collect() + content: parts.into_iter().map(|s| s.to_owned()).collect() }; self.events.lock().fire(&(self.clone(), event)); -- cgit v1.2.3