ToMessage now consumes the struct in the conversion.

This commit is contained in:
Aaron Weiss 2015-04-25 23:13:56 -04:00
parent 42454939d7
commit 83243ffec3
2 changed files with 6 additions and 6 deletions

View file

@ -151,8 +151,8 @@ pub enum Command {
impl ToMessage for Command { impl ToMessage for Command {
/// Converts a Command into a Message. /// Converts a Command into a Message.
fn to_message(&self) -> Message { fn to_message(self) -> Message {
match *self { match self {
Command::PASS(ref p) => Message::new(None, "PASS", None, Some(&p)), Command::PASS(ref p) => Message::new(None, "PASS", None, Some(&p)),
Command::NICK(ref n) => Message::new(None, "NICK", None, Some(&n)), Command::NICK(ref n) => Message::new(None, "NICK", None, Some(&n)),
Command::USER(ref u, ref m, ref r) => Command::USER(ref u, ref m, ref r) =>

View file

@ -56,8 +56,8 @@ impl Message {
} }
impl ToMessage for Message { impl ToMessage for Message {
fn to_message(&self) -> Message { fn to_message(self) -> Message {
self.clone() self
} }
} }
@ -96,11 +96,11 @@ impl FromStr for Message {
/// A trait representing the ability to be converted into a Message. /// A trait representing the ability to be converted into a Message.
pub trait ToMessage { pub trait ToMessage {
/// Converts this to a Message. /// Converts this to a Message.
fn to_message(&self) -> Message; fn to_message(self) -> Message;
} }
impl<'a> ToMessage for &'a str { impl<'a> ToMessage for &'a str {
fn to_message(&self) -> Message { fn to_message(self) -> Message {
self.parse().unwrap() self.parse().unwrap()
} }
} }