irc-proto: Fix all trivial clippy warnings using cargo clippy --fix
This commit is contained in:
parent
3d037df761
commit
b0c5f1fe90
3 changed files with 25 additions and 34 deletions
|
@ -231,13 +231,13 @@ impl<'a> From<&'a Command> for String {
|
||||||
"MODE {}{}",
|
"MODE {}{}",
|
||||||
u,
|
u,
|
||||||
m.iter().fold(String::new(), |mut acc, mode| {
|
m.iter().fold(String::new(), |mut acc, mode| {
|
||||||
acc.push_str(" ");
|
acc.push(' ');
|
||||||
acc.push_str(&mode.to_string());
|
acc.push_str(&mode.to_string());
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
Command::SERVICE(ref n, ref r, ref d, ref t, ref re, ref i) => {
|
Command::SERVICE(ref nick, ref r0, ref dist, ref typ, ref r1, ref info) => {
|
||||||
stringify("SERVICE", &[n, r, d, t, re, i])
|
stringify("SERVICE", &[nick, r0, dist, typ, r1, info])
|
||||||
}
|
}
|
||||||
Command::QUIT(Some(ref m)) => stringify("QUIT", &[m]),
|
Command::QUIT(Some(ref m)) => stringify("QUIT", &[m]),
|
||||||
Command::QUIT(None) => stringify("QUIT", &[]),
|
Command::QUIT(None) => stringify("QUIT", &[]),
|
||||||
|
@ -252,7 +252,7 @@ impl<'a> From<&'a Command> for String {
|
||||||
"MODE {}{}",
|
"MODE {}{}",
|
||||||
u,
|
u,
|
||||||
m.iter().fold(String::new(), |mut acc, mode| {
|
m.iter().fold(String::new(), |mut acc, mode| {
|
||||||
acc.push_str(" ");
|
acc.push(' ');
|
||||||
acc.push_str(&mode.to_string());
|
acc.push_str(&mode.to_string());
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
|
@ -445,12 +445,10 @@ impl Command {
|
||||||
} else if cmd.eq_ignore_ascii_case("MODE") {
|
} else if cmd.eq_ignore_ascii_case("MODE") {
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
raw(cmd, args)
|
raw(cmd, args)
|
||||||
|
} else if args[0].is_channel_name() {
|
||||||
|
Command::ChannelMODE(args[0].to_owned(), Mode::as_channel_modes(&args[1..])?)
|
||||||
} else {
|
} else {
|
||||||
if args[0].is_channel_name() {
|
Command::UserMODE(args[0].to_owned(), Mode::as_user_modes(&args[1..])?)
|
||||||
Command::ChannelMODE(args[0].to_owned(), Mode::as_channel_modes(&args[1..])?)
|
|
||||||
} else {
|
|
||||||
Command::UserMODE(args[0].to_owned(), Mode::as_user_modes(&args[1..])?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if cmd.eq_ignore_ascii_case("SERVICE") {
|
} else if cmd.eq_ignore_ascii_case("SERVICE") {
|
||||||
if args.len() != 6 {
|
if args.len() != 6 {
|
||||||
|
@ -665,7 +663,7 @@ impl Command {
|
||||||
} else if args.len() == 1 {
|
} else if args.len() == 1 {
|
||||||
Command::WHO(Some(args[0].to_owned()), None)
|
Command::WHO(Some(args[0].to_owned()), None)
|
||||||
} else if args.len() == 2 {
|
} else if args.len() == 2 {
|
||||||
Command::WHO(Some(args[0].to_owned()), Some(&args[1][..] == "o"))
|
Command::WHO(Some(args[0].to_owned()), Some(args[1] == "o"))
|
||||||
} else {
|
} else {
|
||||||
raw(cmd, args)
|
raw(cmd, args)
|
||||||
}
|
}
|
||||||
|
@ -907,13 +905,12 @@ impl Command {
|
||||||
raw(cmd, args)
|
raw(cmd, args)
|
||||||
}
|
}
|
||||||
} else if cmd.eq_ignore_ascii_case("METADATA") {
|
} else if cmd.eq_ignore_ascii_case("METADATA") {
|
||||||
if args.len() == 2 {
|
match args.len() {
|
||||||
match args[1].parse() {
|
2 => match args[1].parse() {
|
||||||
Ok(c) => Command::METADATA(args[0].to_owned(), Some(c), None),
|
Ok(c) => Command::METADATA(args[0].to_owned(), Some(c), None),
|
||||||
Err(_) => raw(cmd, args),
|
Err(_) => raw(cmd, args),
|
||||||
}
|
},
|
||||||
} else if args.len() > 2 {
|
3.. => match args[1].parse() {
|
||||||
match args[1].parse() {
|
|
||||||
Ok(c) => Command::METADATA(
|
Ok(c) => Command::METADATA(
|
||||||
args[0].to_owned(),
|
args[0].to_owned(),
|
||||||
Some(c),
|
Some(c),
|
||||||
|
@ -930,9 +927,8 @@ impl Command {
|
||||||
raw(cmd, args)
|
raw(cmd, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
} else {
|
_ => raw(cmd, args),
|
||||||
raw(cmd, args)
|
|
||||||
}
|
}
|
||||||
} else if cmd.eq_ignore_ascii_case("MONITOR") {
|
} else if cmd.eq_ignore_ascii_case("MONITOR") {
|
||||||
if args.len() == 2 {
|
if args.len() == 2 {
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl Message {
|
||||||
args: Vec<&str>,
|
args: Vec<&str>,
|
||||||
) -> Result<Message, error::MessageParseError> {
|
) -> Result<Message, error::MessageParseError> {
|
||||||
Ok(Message {
|
Ok(Message {
|
||||||
tags: tags,
|
tags,
|
||||||
prefix: prefix.map(|p| p.into()),
|
prefix: prefix.map(|p| p.into()),
|
||||||
command: Command::new(command, args)?,
|
command: Command::new(command, args)?,
|
||||||
})
|
})
|
||||||
|
@ -134,7 +134,7 @@ impl Message {
|
||||||
ret.push_str(&tag.0);
|
ret.push_str(&tag.0);
|
||||||
if let Some(ref value) = tag.1 {
|
if let Some(ref value) = tag.1 {
|
||||||
ret.push('=');
|
ret.push('=');
|
||||||
escape_tag_value(&mut ret, &value);
|
escape_tag_value(&mut ret, value);
|
||||||
}
|
}
|
||||||
ret.push(';');
|
ret.push(';');
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,11 +139,7 @@ impl ModeType for ChannelMode {
|
||||||
fn takes_arg(&self) -> bool {
|
fn takes_arg(&self) -> bool {
|
||||||
use self::ChannelMode::*;
|
use self::ChannelMode::*;
|
||||||
|
|
||||||
match *self {
|
matches!(*self, Ban | Exception | Limit | InviteException | Key | Founder | Admin | Oper | Halfop | Voice)
|
||||||
Ban | Exception | Limit | InviteException | Key | Founder | Admin | Oper | Halfop
|
|
||||||
| Voice => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_char(c: char) -> ChannelMode {
|
fn from_char(c: char) -> ChannelMode {
|
||||||
|
@ -234,10 +230,10 @@ where
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Mode::Plus(ref mode, Some(ref arg)) => write!(f, "{}{} {}", "+", mode, arg),
|
Mode::Plus(ref mode, Some(ref arg)) => write!(f, "+{} {}", mode, arg),
|
||||||
Mode::Minus(ref mode, Some(ref arg)) => write!(f, "{}{} {}", "-", mode, arg),
|
Mode::Minus(ref mode, Some(ref arg)) => write!(f, "-{} {}", mode, arg),
|
||||||
Mode::Plus(ref mode, None) => write!(f, "{}{}", "+", mode),
|
Mode::Plus(ref mode, None) => write!(f, "+{}", mode),
|
||||||
Mode::Minus(ref mode, None) => write!(f, "{}{}", "-", mode),
|
Mode::Minus(ref mode, None) => write!(f, "-{}", mode),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,7 +278,7 @@ where
|
||||||
Some('-') => Minus,
|
Some('-') => Minus,
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
return Err(InvalidModeString {
|
return Err(InvalidModeString {
|
||||||
string: pieces.join(" ").to_owned(),
|
string: pieces.join(" "),
|
||||||
cause: InvalidModeModifier { modifier: c },
|
cause: InvalidModeModifier { modifier: c },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -313,12 +309,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: if there are extra args left, this should error
|
// TODO: if there are extra args left, this should error
|
||||||
|
|
||||||
Ok(res)
|
|
||||||
} else {
|
} else {
|
||||||
// No modifier
|
// No modifier
|
||||||
Ok(res)
|
};
|
||||||
}
|
|
||||||
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue