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 {
/// Converts a Command into a Message.
fn to_message(&self) -> Message {
match *self {
fn to_message(self) -> Message {
match self {
Command::PASS(ref p) => Message::new(None, "PASS", None, Some(&p)),
Command::NICK(ref n) => Message::new(None, "NICK", None, Some(&n)),
Command::USER(ref u, ref m, ref r) =>

View file

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