From: Simon Tatham Date: Mon, 1 Jan 2024 13:50:00 +0000 (+0000) Subject: Remove lots of commas after braced match arms. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=04530126b126701ac69efca3111d57ff3be5286a;p=mastodonochrome.git Remove lots of commas after braced match arms. I only just noticed from reading someone else's Rust code that they aren't syntactically necessary! --- diff --git a/src/activity_stack.rs b/src/activity_stack.rs index fff8f47..77bc551 100644 --- a/src/activity_stack.rs +++ b/src/activity_stack.rs @@ -104,7 +104,7 @@ impl ActivityStack { Activity::Util(x) => { self.overlay = None; self.util = Some(x); - }, + } Activity::NonUtil(x) => { self.util = None; self.overlay = None; @@ -118,13 +118,13 @@ impl ActivityStack { }; self.nonutil.truncate(trunc); self.nonutil.push(y); - }, + } } - }, + } Activity::Overlay(x) => { self.util = self.initial_util.clone(); self.overlay = Some(x); - }, + } } } @@ -134,7 +134,7 @@ impl ActivityStack { _ => match self.nonutil.last() { Some(y) => Activity::NonUtil(y.clone()), _ => Activity::NonUtil(NonUtilityActivity::MainMenu), - }, + } } } diff --git a/src/auth.rs b/src/auth.rs index 098db84..ce195d9 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -15,10 +15,10 @@ impl std::fmt::Display for AuthError { match self { AuthError::Nonexistent(_) => { write!(f, "not logged in") - }, + } AuthError::Bad(ref msg) => { write!(f, "unable to read authentication: {}", msg) - }, + } } } } diff --git a/src/client.rs b/src/client.rs index ddc4453..3a732a0 100644 --- a/src/client.rs +++ b/src/client.rs @@ -301,7 +301,7 @@ impl Client { Ok(st) => Ok(st), Err(e) => { Err(ClientError::UrlError(url.clone(), e.to_string())) - }, + } } }?; if st.id != id { @@ -346,7 +346,7 @@ impl Client { Ok(st) => Ok(st), Err(e) => { Err(ClientError::UrlError(url.clone(), e.to_string())) - }, + } } }?; if not.id != id { @@ -391,27 +391,27 @@ impl Client { FeedId::Home => Req::get("timelines/home"), FeedId::Local => { Req::get("timelines/public").param("local", true) - }, + } FeedId::Public => { Req::get("timelines/public").param("local", false) - }, + } FeedId::Hashtag(ref tag) => { Req::get(&format!("timelines/tag/{}", &tag)) - }, + } FeedId::User(id, boosts, replies) => { Req::get(&format!("accounts/{}/statuses", id)) .param("exclude_reblogs", *boosts == Boosts::Hide) .param("exclude_replies", *replies == Replies::Hide) - }, + } FeedId::Mentions => { Req::get("notifications").param("types[]", "mention") - }, + } FeedId::Ego => { Req::get("notifications") .param("types[]", "reblog") .param("types[]", "follow") .param("types[]", "favourite") - }, + } }; let req = match ext { @@ -449,20 +449,20 @@ impl Client { Ok(sts) => Ok(sts), Err(e) => { Err(ClientError::UrlError(url.clone(), e.to_string())) - }, + } }?; for st in &sts { self.cache_status(st); } sts.iter().rev().map(|st| st.id.clone()).collect() - }, + } FeedId::Mentions | FeedId::Ego => { let mut nots: Vec = match serde_json::from_str( &body) { Ok(nots) => Ok(nots), Err(e) => { Err(ClientError::UrlError(url.clone(), e.to_string())) - }, + } }?; match id { @@ -476,21 +476,21 @@ impl Client { not.ntype == NotificationType::Mention && not.status.is_some() }); - }, + } FeedId::Ego => { nots.retain(|not| { not.ntype == NotificationType::Reblog || not.ntype == NotificationType::Follow || not.ntype == NotificationType::Favourite }); - }, + } _ => panic!("outer match passed us {:?}", id), } for not in ¬s { self.cache_notification(not); } nots.iter().rev().map(|not| not.id.clone()).collect() - }, + } }; let any_new = !ids.is_empty(); @@ -500,20 +500,20 @@ impl Client { ids: ids, origin: 0, }); - }, + } FeedExtend::Future => { let feed = self.feeds.get_mut(id).unwrap(); for id in ids.iter() { feed.ids.push_back(id.to_string()); } - }, + } FeedExtend::Past => { let feed = self.feeds.get_mut(id).unwrap(); for id in ids.iter().rev() { feed.ids.push_front(id.to_string()); feed.origin -= 1; } - }, + } } Ok(any_new) @@ -604,7 +604,7 @@ impl Client { updates.insert(id.clone()); } } - }, + } // FIXME: we probably _should_ handle EOF from the // subthread, though I'm not quite sure how yet. Stream diff --git a/src/coloured_string.rs b/src/coloured_string.rs index cb3a7e1..72d3b31 100644 --- a/src/coloured_string.rs +++ b/src/coloured_string.rs @@ -300,7 +300,7 @@ impl<'a> Iterator for ColouredStringSplitIterator<'a> { } else { None } - }, + } (Some((_, tc)), Some(_)) => { let mut tpos: usize = 0; let mut cpos: usize = 0; @@ -315,12 +315,12 @@ impl<'a> Iterator for ColouredStringSplitIterator<'a> { match (textit.next(), colourit.next()) { (None, None) => { break (textslice.len(), colourslice.len()); - }, + } (Some((ti, tc)), Some((ci, _))) => { tpos = ti; cpos = ci; last_tc = tc; - }, + } _ => panic!("length mismatch in CSSI"), }; }; @@ -330,7 +330,7 @@ impl<'a> Iterator for ColouredStringSplitIterator<'a> { text: &textslice[..textend], colour: &colourslice[..colourend], }) - }, + } _ => panic!("length mismatch in CSSI"), } } diff --git a/src/config.rs b/src/config.rs index e6c5010..6308468 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,14 +18,14 @@ impl std::fmt::Display for ConfigError { { match self { #[cfg(unix)] - ConfigError::XDG(e) => { e.fmt(f) }, + ConfigError::XDG(e) => { e.fmt(f) } #[cfg(windows)] ConfigError::Env(e) => { // FIXME: how _should_ we include the information // about what environment variable? write!(f, "%APPDATA%: {}", e) - }, + } } } } diff --git a/src/editor.rs b/src/editor.rs index 8f5c9ed..65178e0 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -38,7 +38,7 @@ impl EditorCore { end += 1; } Some((width, end - pos)) - }, + } } } @@ -322,7 +322,7 @@ impl SingleLineEditor { Some((w, b)) => { head += b; currwidth += w; - }, + } } } else { match self.core.char_width_and_bytes(tail) { @@ -334,7 +334,7 @@ impl SingleLineEditor { counted_initial_trunc_marker = true; avail_width = avail_width.saturating_sub(1); } - }, + } } } } diff --git a/src/file.rs b/src/file.rs index 1f244bb..e5276aa 100644 --- a/src/file.rs +++ b/src/file.rs @@ -290,7 +290,7 @@ impl File { match &mut self.contents.extender { Some(ref mut ext) => { ext.set_primed(at_top); - }, + } _ => (), }; if let Some(ei) = self.contents.extender_index() { @@ -498,15 +498,15 @@ impl Up => { self.move_up(1); LogicalAction::Nothing - }, + } Pr('-') | Pr('b') | Pr('B') | PgUp | Left => { self.move_up(max(1, h - min(h, 3))); LogicalAction::Nothing - }, + } Down => { self.move_down(1); LogicalAction::Nothing - }, + } Return => { let oldpos = self.pos; self.move_down(1); @@ -515,11 +515,11 @@ impl } else { LogicalAction::Nothing } - }, + } Space | PgDn | Right => { self.move_down(max(1, h - min(h, 3))); LogicalAction::Nothing - }, + } Pr('0') | Home => { if self.at_top() && self.contents.extender.is_some() { let action = match self.contents.source.try_extend(client) { @@ -546,7 +546,7 @@ impl self.contents.update_items(client); LogicalAction::Nothing - }, + } Err(e) => LogicalAction::Error(e), }; self.ensure_enough_rendered(); diff --git a/src/html.rs b/src/html.rs index b470ad8..73cb40a 100644 --- a/src/html.rs +++ b/src/html.rs @@ -173,7 +173,7 @@ fn to_coloured_string(tl: &TaggedLine>) -> ColouredString { None => ' ', }; cs.push_str(&ColouredString::uniform(&ts.s, c).slice()); - }, + } _ => (), } } diff --git a/src/scan_re.rs b/src/scan_re.rs index b115e74..304d52c 100644 --- a/src/scan_re.rs +++ b/src/scan_re.rs @@ -21,7 +21,7 @@ impl Findable { None => break Some((ms, me)), Some(_) => start = ms + 1, } - }, + } }; } } diff --git a/src/text.rs b/src/text.rs index 2bc8436..3388f26 100644 --- a/src/text.rs +++ b/src/text.rs @@ -81,7 +81,7 @@ impl TextFragment for SeparatorLine { suffix = &display_pre + ColouredString::uniform(&datestr, 'D') + &display_post + suffix; - }, + } _ => (), } if self.boosted { @@ -591,7 +591,7 @@ impl TextFragment for Html { Html::Rt(ref rt) => html::render(rt, width - min(width, 1)), Html::Bad(e) => vec! { ColouredString::uniform(e, '!'), - }, + } } } } @@ -939,7 +939,7 @@ impl Media { .collect(); trim_para_list(&mut paras); paras - }, + } }; Media { @@ -1421,7 +1421,7 @@ impl StatusDisplay { )), }; Some(InReplyToLine::new(parent_text)) - }, + } }; let content = Html::new(&st.content); diff --git a/src/tui.rs b/src/tui.rs index 0cad060..32a580d 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -268,7 +268,7 @@ impl Tui { Some(OurKey::Pr(' ')) => Some(OurKey::Space), other => other, } - }, + } _ => None, }; if let Some(main) = main { @@ -327,24 +327,24 @@ impl Tui { ourkey, &mut self.client) { PhysicalAction::Beep => { Self::beep()? - }, + } PhysicalAction::Exit => { break 'outer Ok(()); - }, + } PhysicalAction::Error(err) => { break 'outer Err(err); - }, + } PhysicalAction::Nothing => (), } } } - }, + } _ => (), } - }, + } Ok(SubthreadEvent::StreamEv(update)) => { match self.client.process_stream_update(update) { Ok(feeds_updated) => { @@ -352,19 +352,19 @@ impl Tui { &mut self.client) { PhysicalAction::Beep => { Self::beep()? - }, + } PhysicalAction::Exit => { break 'outer Ok(()); - }, + } PhysicalAction::Error(err) => { break 'outer Err(err); - }, + } PhysicalAction::Nothing => (), } - }, + } // FIXME: errors here should go in the Error Log _ => (), @@ -562,20 +562,20 @@ impl TuiLogicalState { self.activity_stack.goto(activity); self.changed_activity(client); PhysicalAction::Nothing - }, + } LogicalAction::Pop => { self.activity_stack.pop(); self.changed_activity(client); PhysicalAction::Nothing - }, + } LogicalAction::PopOverlaySilent => { self.pop_overlay_activity(); PhysicalAction::Nothing - }, + } LogicalAction::PopOverlayBeep => { self.pop_overlay_activity(); PhysicalAction::Beep - }, + } LogicalAction::Error(_) => PhysicalAction::Beep, // FIXME: Error Log } }