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