From c67d6c211918f8b787b862bb580c41224a8d50c7 Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Tue, 21 Apr 2015 13:42:24 +0200 Subject: Parse and format PASS, NICK, USER, OPER, PING, PONG, JOIN, PART --- src/message.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/message.rs') diff --git a/src/message.rs b/src/message.rs index 63b1079..b37ba6b 100644 --- a/src/message.rs +++ b/src/message.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use std::string::{ ToString }; use std::borrow::{ ToOwned }; -use std::ops::Range; +use std::ops::{ Deref, Range }; use ::IrscError; @@ -39,7 +39,7 @@ impl Message { } #[allow(unused_assignments)] - pub fn format(prefix: Option<&str>, command: &str, content: Vec<&str>, suffix: Option<&str>, msg_type: MsgType) -> Message { + pub fn format>(prefix: Option, command: T, content: Vec, suffix: Option, msg_type: MsgType) -> Message { let mut s = String::with_capacity(512); let mut i = 0; @@ -53,7 +53,7 @@ impl Message { } let i_command = i as u16..(i + command.len()) as u16; - s.push_str(command); + s.push_str(&*command); s.push(' '); i += 1 + command.len(); @@ -90,6 +90,7 @@ impl Message { pub fn command(&self) -> &str { self.range(&self.command) } pub fn content(&self) -> Vec<&str> { self.content.iter().map(|r| self.range(&r)).collect() } pub fn suffix(&self) -> Option<&str> { self.suffix.as_ref().map(|r| self.range(r)) } + pub fn elements(&self) -> Vec<&str> { let mut s = self.content(); self.suffix().map(|f| s.push(f)); s } } impl FromStr for Message { -- cgit v1.2.3