Fix clippy lints

This commit is contained in:
Yash Karandikar 2022-09-23 08:50:23 -05:00
parent 8c60211570
commit d4060c07e1

View file

@ -16,9 +16,9 @@ struct WeechatNotify {
impl Plugin for WeechatNotify { impl Plugin for WeechatNotify {
fn init(_: &Weechat, _: Args) -> Result<Self, ()> { fn init(_: &Weechat, _: Args) -> Result<Self, ()> {
let _h1 = SignalHook::new("weechat_highlight", notify)?; let h1 = SignalHook::new("weechat_highlight", notify)?;
let _h2 = SignalHook::new("irc_pv", notify)?; let h2 = SignalHook::new("irc_pv", notify)?;
Ok(Self { _h1, _h2 }) Ok(Self { _h1: h1, _h2: h2 })
} }
} }
@ -28,17 +28,16 @@ fn notify_inner(
data: Option<SignalData>, data: Option<SignalData>,
) -> Result<(), String> { ) -> Result<(), String> {
if let Some(SignalData::String(s)) = data { if let Some(SignalData::String(s)) = data {
let mut arr: Vec<&str> = s.split("\t").collect(); let mut arr: Vec<&str> = s.split('\t').collect();
if arr.len() == 1 { if arr.len() == 1 {
let a = arr[0].split("PRIVMSG").collect::<Vec<&str>>(); let a = arr[0].split("PRIVMSG").collect::<Vec<&str>>();
let b = a[0] let b = a[0]
.split("!") .split('!')
.next() .next()
.map(|s| s.strip_prefix(":")) .and_then(|s| s.strip_prefix(':'))
.flatten()
.ok_or_else(|| "malformed data".to_string())?; .ok_or_else(|| "malformed data".to_string())?;
let c = a[1] let c = a[1]
.split(":") .split(':')
.nth(1) .nth(1)
.ok_or_else(|| "malformed data".to_string())?; .ok_or_else(|| "malformed data".to_string())?;
arr = vec![b, c]; arr = vec![b, c];