From f190d7efc8f19ed4f6965cd29f09cf2068c9c60e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 6 Dec 2020 01:50:02 +0000 Subject: [PATCH] formatting, some from rustfmt (manually picked) Signed-off-by: Ian Jackson --- src/toml-de.rs | 14 ++++++-------- src/tz.rs | 10 +++++----- src/updates.rs | 44 ++++++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/toml-de.rs b/src/toml-de.rs index 16f79e7e..fc790caa 100644 --- a/src/toml-de.rs +++ b/src/toml-de.rs @@ -42,7 +42,7 @@ fn str_deserialize<'de, S: DeserializeSeed<'de>> pub struct TomlDe<'de>(pub &'de toml::Value); -struct SA<'de> (slice::Iter<'de, toml::Value>); +struct SA<'de>(slice::Iter<'de, toml::Value>); impl<'de> SeqAccess<'de> for SA<'de> { type Error = Error; @@ -61,7 +61,7 @@ impl<'de> SeqAccess<'de> for SA<'de> { } } -struct MA<'de> (Peekable>); +struct MA<'de>(Peekable>); impl<'de> MapAccess<'de> for MA<'de> { type Error = Error; @@ -161,7 +161,7 @@ impl<'de> Deserializer<'de> for TomlDe<'de> { if let None = s.next(); then { return vi.visit_enum(EA { k, v }) } }, - _ => {}, + _ => {} } // hopefully the format will figure it out, or produce an error visit(vi, &self.0)? @@ -174,15 +174,13 @@ impl<'de> Deserializer<'de> for TomlDe<'de> { } #[throws(Error)] -pub fn from_value<'de, T: Deserialize<'de>> (tv: &'de toml::Value) -> T -{ +pub fn from_value<'de, T: Deserialize<'de>>(tv: &'de toml::Value) -> T { Deserialize::deserialize(TomlDe(tv))? } #[throws(Error)] -pub fn from_str (s: &str) -> T -{ - let tv : toml::Value = s.parse().map_err(Error::TomlSyntax)?; +pub fn from_str(s: &str) -> T { + let tv: toml::Value = s.parse().map_err(Error::TomlSyntax)?; // dbg!(&tv); from_value(&tv)? } diff --git a/src/tz.rs b/src/tz.rs index 863b3155..5922531e 100644 --- a/src/tz.rs +++ b/src/tz.rs @@ -4,19 +4,19 @@ use crate::imports::*; -use parking_lot::{RwLock, const_rwlock}; +use parking_lot::{const_rwlock, RwLock}; #[derive(SerializeDisplay)] #[derive(DeserializeFromStr)] #[derive(Clone,Debug)] -pub struct Timezone (Arc); +pub struct Timezone(Arc); #[derive(Clone,Debug,Default)] struct TzInfo { name: String, ctz: Option, } - + impl Timezone { pub fn name(&self) -> &str { &self.0.name @@ -28,7 +28,7 @@ impl Timezone { fn format_tz<'r, TZ: chrono::TimeZone>( tz: &TZ, ts: Timestamp, fmt: &'r str ) -> chrono::format::DelayedFormat> - where ::Offset : Display + where ::Offset: Display { use chrono::DateTime; let dt = tz.timestamp_opt(ts.0.try_into().ok()?, 0).single()?; @@ -90,7 +90,7 @@ impl FromStr for Timezone { Err(emsg) => { error!("Error loading timezone {:?}: {}, using UTC", name, emsg); Arc::new(TzInfo { name, ctz: None }) - }, + } } }; let out = Timezone(out); diff --git a/src/updates.rs b/src/updates.rs index 5a4ad4e8..1d93f7c6 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -16,7 +16,7 @@ pub struct ClientSequence(u64); #[derive(Debug)] // not Default pub struct ExecuteGameChangeUpdates { - pub pcs: Vec<(PieceId,PieceUpdateOp<(),()>)>, + pub pcs: Vec<(PieceId, PieceUpdateOp<(), ()>)>, pub log: Vec, pub raw: Option>, } @@ -28,23 +28,23 @@ pub type PlayerUpdatesLog = #[derive(Debug)] pub struct PlayerUpdates { - log : PlayerUpdatesLog, - cv : Arc, + log: PlayerUpdatesLog, + cv: Arc, } #[derive(Debug)] pub struct PreparedUpdate { - pub gen : Generation, + pub gen: Generation, pub when: Instant, - pub us : Vec, + pub us: Vec, } #[derive(Debug)] pub enum PreparedUpdateEntry { Piece { by_client: IsResponseToClientOp, - piece : VisiblePieceId, - op : PieceUpdateOp, + piece: VisiblePieceId, + op: PieceUpdateOp, }, SetTableSize(Pos), SetTableColour(Colour), @@ -56,18 +56,18 @@ pub enum PreparedUpdateEntry { #[derive(Debug,Clone,Serialize)] pub struct PreparedPieceState { - pub pos : Pos, - pub svg : Html, - pub held : Option, - pub z : ZCoord, - pub zg : Generation, - pub pinned : bool, + pub pos: Pos, + pub svg: Html, + pub held: Option, + pub z: ZCoord, + pub zg: Generation, + pub pinned: bool, pub uos: Vec, } #[derive(Serialize,Debug)] pub struct DataLoadPlayer { - dasharray : String, + dasharray: String, } // ---------- piece updates ---------- @@ -97,18 +97,18 @@ pub struct TransmitUpdate<'u> ( #[derive(Debug,Serialize)] enum TransmitUpdateEntry<'u> { Recorded { - piece : VisiblePieceId, - cseq : ClientSequence, - zg : Option, + piece: VisiblePieceId, + cseq: ClientSequence, + zg: Option, svg: Option<&'u Html>, // IsResponseToClientOp::UpdateSvg }, Piece { - piece : VisiblePieceId, - op : PieceUpdateOp<&'u PreparedPieceState, &'u ZLevel>, + piece: VisiblePieceId, + op: PieceUpdateOp<&'u PreparedPieceState, &'u ZLevel>, }, RecordedUnpredictable { - piece : VisiblePieceId, - cseq : ClientSequence, + piece: VisiblePieceId, + cseq: ClientSequence, ns: &'u PreparedPieceState, }, SetTableSize(Pos), @@ -148,7 +148,7 @@ impl PlayerUpdatesBuildContext { impl PlayerUpdates { pub fn new_begin(gs: &GameState) -> PlayerUpdatesBuildContext { let u1 = Arc::new(PreparedUpdate { - gen : gs.gen, + gen: gs.gen, when: Instant::now(), us: vec![], }); -- 2.30.2