From 2735d12f763f35ddbe1daf39237092add2a110ea Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 6 Dec 2020 01:02:53 +0000 Subject: [PATCH] formatting, some from rustfmt (manually picked) Signed-off-by: Ian Jackson --- src/gamestate.rs | 36 ++++++++++++++++++------------------ src/global.rs | 8 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index 6f9e3ec4..7ac57e15 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -86,9 +86,9 @@ pub struct CommittedLogEntry { // ---------- piece trait, and rendering ---------- #[typetag::serde] -pub trait Outline : Send + Debug { - fn surround_path(&self, pri : &PieceRenderInstructions) -> Result; - fn thresh_dragraise(&self, pri : &PieceRenderInstructions) +pub trait Outline: Send + Debug { + fn surround_path(&self, pri: &PieceRenderInstructions) -> Result; + fn thresh_dragraise(&self, pri: &PieceRenderInstructions) -> Result, IE>; fn bbox_approx(&self) -> [Pos;2]; } @@ -108,7 +108,7 @@ pub struct UoDescription { } #[typetag::serde] -pub trait Piece : Outline + Send + Debug { +pub trait Piece: Outline + Send + Debug { fn nfaces(&self) -> RawFaceId; #[throws(InternalError)] @@ -125,7 +125,7 @@ pub trait Piece : Outline + Send + Debug { // #[throws] doesn't work here for some reason fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions) -> IR; - fn describe_html(&self, face : Option) -> Html; + fn describe_html(&self, face: Option) -> Html; fn delete_hook(&self, _p: &PieceState, _gs: &mut GameState) -> ExecuteGameChangeUpdates { @@ -137,14 +137,14 @@ pub trait Piece : Outline + Send + Debug { #[derive(Debug,Copy,Clone)] pub struct PieceRenderInstructions { - pub id : VisiblePieceId, - pub face : FaceId, + pub id: VisiblePieceId, + pub face: FaceId, } #[typetag::serde(tag="type")] -pub trait PieceSpec : Debug { +pub trait PieceSpec: Debug { fn count(&self) -> usize { 1 } - fn load(&self, i: usize) -> Result,SpecError>; + fn load(&self, i: usize) -> Result, SpecError>; } // ========== implementations ========== @@ -156,7 +156,7 @@ impl Generation { } impl Display for Generation { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - Display::fmt(&self.0,f) + Display::fmt(&self.0, f) } } @@ -176,7 +176,7 @@ impl Timestamp { } } -pub trait ClampTable : Sized { +pub trait ClampTable: Sized { fn clamped(self, range: Self) -> (Self, bool); } @@ -211,7 +211,7 @@ impl Html { impl Debug for Html { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - const MAX : usize = 23; + const MAX: usize = 23; if self.0.len() < MAX { write!(f, "<{}>", &self.0) } else { @@ -239,14 +239,14 @@ impl PieceState { } pub trait PieceExt { - fn make_defs(&self, pri : &PieceRenderInstructions) -> Result; - fn describe_pri(&self, pri : &PieceRenderInstructions) -> Html; + fn make_defs(&self, pri: &PieceRenderInstructions) -> Result; + fn describe_pri(&self, pri: &PieceRenderInstructions) -> Html; fn ui_operations(&self) -> Result, IE>; } impl PieceExt for T where T: Piece + ?Sized { #[throws(IE)] - fn make_defs(&self, pri : &PieceRenderInstructions) -> Html { + fn make_defs(&self, pri: &PieceRenderInstructions) -> Html { let mut defs = Html(String::new()); let dragraise = match self.thresh_dragraise(pri)? { Some(n) if n < 0 => throw!(SE::NegativeDragraise), @@ -264,7 +264,7 @@ impl PieceExt for T where T: Piece + ?Sized { defs } - fn describe_pri(&self, pri : &PieceRenderInstructions) -> Html { + fn describe_pri(&self, pri: &PieceRenderInstructions) -> Html { self.describe_html(Some(pri.face)) } @@ -316,8 +316,8 @@ impl GameState { // ========== ad-hoc and temporary ========== -pub fn make_pieceid_visible(p : PieceId) -> VisiblePieceId { +pub fn make_pieceid_visible(p: PieceId) -> VisiblePieceId { // todo-lens need to do censorship mapping here - let kd : slotmap::KeyData = p.into(); + let kd: slotmap::KeyData = p.into(); VisiblePieceId(kd) } diff --git a/src/global.rs b/src/global.rs index eda99477..939ed118 100644 --- a/src/global.rs +++ b/src/global.rs @@ -6,8 +6,8 @@ use crate::imports::*; -use std::sync::PoisonError; use slotmap::dense as sm; +use std::sync::PoisonError; type ME = MgmtError; type ESU = ErrorSignaledViaUpdate; @@ -16,11 +16,11 @@ type ESU = ErrorSignaledViaUpdate; visible_slotmap_key!{ ClientId('C') } -const MAX_CLIENT_INACTIVITY : Duration = Duration::from_secs(200); +const MAX_CLIENT_INACTIVITY: Duration = Duration::from_secs(200); -const GAME_SAVE_LAG : Duration = Duration::from_millis(500); +const GAME_SAVE_LAG: Duration = Duration::from_millis(500); -const MAX_LOG_AGE : Duration = Duration::from_secs(10 * 86400); +const MAX_LOG_AGE: Duration = Duration::from_secs(10 * 86400); #[derive(Hash,Ord,PartialOrd,Eq,PartialEq,Serialize)] #[repr(transparent)] -- 2.30.2