From 8bad1c07ec819cba81658633bdb67dc951456268 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 1 Feb 2021 00:09:48 +0000 Subject: [PATCH] style: Remove space before :, etc., in src/*.rs Signed-off-by: Ian Jackson --- src/accounts.rs | 4 ++-- src/config.rs | 13 ++++++------- src/error.rs | 6 +++--- src/gamestate.rs | 4 ++-- src/global.rs | 40 ++++++++++++++++++++-------------------- src/keydata.rs | 6 +++--- src/pieces.rs | 6 +++--- src/shapelib.rs | 14 +++++++------- src/slotmap-slot-idx.rs | 12 ++++++------ src/spec.rs | 2 +- src/sse.rs | 16 ++++++++-------- src/ui.rs | 2 +- src/updates.rs | 11 ++++++----- 13 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/accounts.rs b/src/accounts.rs index 568e3ca6..0a6a9259 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -121,7 +121,7 @@ impl AccountScope { > (&'out self, ns: NS, mut f: F) { - const ENCODE : percent_encoding::AsciiSet = + const ENCODE: percent_encoding::AsciiSet = percent_encoding::NON_ALPHANUMERIC .remove(b'-'); @@ -447,7 +447,7 @@ pub mod loaded_acl { use crate::imports::*; use authproofs::*; - pub trait Perm : FromPrimitive + ToPrimitive + + pub trait Perm: FromPrimitive + ToPrimitive + Copy + Eq + Hash + Sync + Send + 'static { type Auth; diff --git a/src/config.rs b/src/config.rs index 4d9fd9df..7fb0bcac 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,12 +10,11 @@ pub const EXIT_SITUATION : i32 = 8; pub const EXIT_USAGE : i32 = 12; pub const EXIT_DISASTER : i32 = 16; -pub const DEFAULT_CONFIG_DIR : &str = "/etc/otter"; -pub const DEFAULT_CONFIG_LEAFNAME : &str = "server.toml"; - +pub const DEFAULT_CONFIG_DIR : &str = "/etc/otter"; +pub const DEFAULT_CONFIG_LEAFNAME : &str = "server.toml"; pub const DEFAULT_SENDMAIL_PROGRAM : &str = "/usr/sbin/sendmail"; -pub const DAEMON_STARTUP_REPORT : &str = "otter-daemon started"; +pub const DAEMON_STARTUP_REPORT: &str = "otter-daemon started"; pub const LOG_ENV_VAR: &str = "OTTER_LOG"; #[derive(Deserialize,Debug,Clone)] @@ -97,7 +96,7 @@ impl TryFrom for WholeServerConfig { let wasm_dir = defpath(wasm_dir, "assets" ); let nwtemplate_dir = defpath(nwtemplate_dir, "nwtemplates" ); let bundled_sources = defpath(bundled_sources, "bundled-sources" ); - const DEFAULT_LIBRARY_GLOB : &str = "library/*.toml"; + const DEFAULT_LIBRARY_GLOB: &str = "library/*.toml"; let shapelibs = shapelibs.unwrap_or_else(||{ let glob = defpath(None, DEFAULT_LIBRARY_GLOB); @@ -213,7 +212,7 @@ impl ServerConfig { let mut buf = String::new(); File::open(&config_filename).with_context(||config_filename.to_string())? .read_to_string(&mut buf)?; - let spec : ServerConfigSpec = toml_de::from_str(&buf)?; + let spec: ServerConfigSpec = toml_de::from_str(&buf)?; let whole = spec.try_into()?; set_config(whole); } @@ -234,7 +233,7 @@ impl ServerConfig { pub fn save_dir(&self) -> &String { let st = GLOBAL.save_area_lock.lock().unwrap(); - let mut _f : &File = st.as_ref().unwrap(); + let mut _f: &File = st.as_ref().unwrap(); &self.save_dir } } diff --git a/src/error.rs b/src/error.rs index ce8cc072..2311f3bd 100644 --- a/src/error.rs +++ b/src/error.rs @@ -182,14 +182,14 @@ macro_rules! some_slotmap { some_slotmap!{DenseSlotMap} some_slotmap!{SecondarySlotMap} -impl IdForById for T where T : AccessId { +impl IdForById for T where T: AccessId { type Error = T::Error; - const ERROR : Self::Error = ::ERROR; + const ERROR: Self::Error = ::ERROR; } impl IdForById for PieceId { type Error = OE; - const ERROR : OE = OE::PieceGone; + const ERROR: OE = OE::PieceGone; } #[macro_export] diff --git a/src/gamestate.rs b/src/gamestate.rs index 883a52ab..1704761b 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -41,7 +41,7 @@ pub struct Html(pub String); #[serde(transparent)] pub struct Timestamp(pub u64); /* time_t */ -pub const DEFAULT_TABLE_SIZE : Pos = PosC([ 400, 200 ]); +pub const DEFAULT_TABLE_SIZE: Pos = PosC([ 400, 200 ]); // ---------- general data types ---------- @@ -251,7 +251,7 @@ impl VisiblePieceAngle { impl PieceState { #[throws(IE)] - pub fn prep_piecestate(&self, p: &dyn Piece, pri : &PieceRenderInstructions) + pub fn prep_piecestate(&self, p: &dyn Piece, pri: &PieceRenderInstructions) -> PreparedPieceState { PreparedPieceState { pos : self.pos, diff --git a/src/global.rs b/src/global.rs index fa8523ed..b504cf83 100644 --- a/src/global.rs +++ b/src/global.rs @@ -297,7 +297,7 @@ impl Instance { let name = Arc::new(name); let g = Instance { - name : name.clone(), + name: name.clone(), gs, acl, ipieces: PiecesLoaded(default()), clients: default(), @@ -308,9 +308,9 @@ impl Instance { }; let cont = InstanceContainer { - live : true, - game_dirty : false, - access_dirty : false, + live: true, + game_dirty: false, + access_dirty: false, g, }; @@ -402,7 +402,7 @@ impl Instance { _: Authorisation) -> Vec> { let games = GLOBAL.games_table.read().unwrap(); - let out : Vec> = + let out: Vec> = games.keys() .filter(|k| account == None || account == Some(&k.account)) .cloned() @@ -621,8 +621,8 @@ impl<'ig> InstanceGuard<'ig> { // We make a copy so if the save fails, we can put everything back let mut players = self.c.g.gs.players.clone(); - let old_players : Vec<_> = old_players_set.iter().cloned().collect(); - let old_gpls : Vec<_> = old_players.iter().cloned().map(|oldplayer| { + let old_players: Vec<_> = old_players_set.iter().cloned().collect(); + let old_gpls: Vec<_> = old_players.iter().cloned().map(|oldplayer| { players.remove(oldplayer) }).collect(); @@ -708,7 +708,7 @@ impl<'ig> InstanceGuard<'ig> { self.tokens_deregister_for_id( |id:PlayerId| old_players_set.contains(&id) ); - let old_ipls : Vec<_> = old_players.iter().cloned().map( + let old_ipls: Vec<_> = old_players.iter().cloned().map( |oldplayer| self.iplayers.remove(oldplayer) .map(|ipr| ipr.ipl) ).collect(); @@ -813,8 +813,8 @@ impl<'ig> InstanceGuard<'ig> { }); let iad = InstanceAccessDetails { - gref : self.gref.clone(), - ident : player, + gref: self.gref.clone(), + ident: player, acctid }; self.token_register(token.clone(), iad); @@ -886,7 +886,7 @@ impl<'ig> InstanceGuard<'ig> { } fn forget_all_tokens(tokens: &mut TokenRegistry) { - let global : &RwLock> = AccessId::global_tokens(PRIVATE_Y); + let global: &RwLock> = AccessId::global_tokens(PRIVATE_Y); let mut global = global.write().unwrap(); for t in tokens.tr.drain() { global.remove(&t); } } @@ -941,7 +941,7 @@ fn savefilename_parse(leaf: &[u8]) -> SavefilenameParseResult { let name = InstanceName::from_str(&rhs)?; GameFile { - access_leaf : [ b"a-", after_ftype_prefix ].concat(), + access_leaf: [ b"a-", after_ftype_prefix ].concat(), name, } } @@ -961,7 +961,7 @@ impl InstanceGuard<'_> { f.flush() .with_context(||format!("save: flush {:?}",&tmp))?; drop( - f.into_inner().map_err(|e| { let e : io::Error = e.into(); e }) + f.into_inner().map_err(|e| { let e: io::Error = e.into(); e }) .with_context(||format!("save: close {:?}",&tmp))? ); let out = savefilename(&self.name, prefix,""); @@ -1057,7 +1057,7 @@ impl InstanceGuard<'_> { let pu_bc = PlayerUpdates::new_begin(&gs); - let iplayers : SecondarySlotMap = { + let iplayers: SecondarySlotMap = { let a = aplayers; a.into_iter() }.filter_map(|(player, ipl)| { @@ -1115,8 +1115,8 @@ impl InstanceGuard<'_> { if let Some(acctid) = acctid; let iad = InstanceAccessDetails { acctid, - gref : gref.clone(), - ident : player, + gref: gref.clone(), + ident: player, }; then { global.insert(RawToken(token), iad); } } } @@ -1179,7 +1179,7 @@ pub type TokenTable = HashMap>; pub trait AccessId: Copy + Clone + 'static { type Error: Into; - const ERROR : Self::Error; + const ERROR: Self::Error; fn global_tokens(_:PrivateCaller) -> &'static RwLock>; fn tokens_registry(ig: &mut Instance, _:PrivateCaller) -> &mut TokenRegistry; @@ -1226,14 +1226,14 @@ impl RawToken { } } -pub fn lookup_token(s : &RawTokenVal) +pub fn lookup_token(s: &RawTokenVal) -> Result, Id::Error> { Id::global_tokens(PRIVATE_Y).read().unwrap().get(s).cloned() .ok_or(Id::ERROR) } #[throws(OE)] -pub fn record_token ( +pub fn record_token ( ig: &mut InstanceGuard, iad: InstanceAccessDetails ) -> RawToken { @@ -1251,7 +1251,7 @@ pub fn process_all_players_for_account< { for gref in games.values() { let c = gref.lock_even_poisoned(); - let remove : Vec<_> = c.g.iplayers.iter().filter_map(|(player,pr)| { + let remove: Vec<_> = c.g.iplayers.iter().filter_map(|(player,pr)| { if pr.ipl.acctid == acctid { Some(player) } else { None } }).collect(); let mut ig = InstanceGuard { gref: gref.clone(), c }; diff --git a/src/keydata.rs b/src/keydata.rs index 0853e278..291e91ce 100644 --- a/src/keydata.rs +++ b/src/keydata.rs @@ -12,7 +12,7 @@ type SKD = slotmap::KeyData; macro_rules! display_consequential_impls { ( $x:path ) => { impl From<$x> for String { - fn from(p : $x) -> String { format!("{}",p) } + fn from(p: $x) -> String { format!("{}",p) } } impl Debug for $x { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { @@ -68,10 +68,10 @@ macro_rules! visible_slotmap_key { fn data(&self) -> slotmap::KeyData { self.0 } } impl From for $x { - fn from(d : slotmap::KeyData) -> Self { $x(d) } + fn from(d: slotmap::KeyData) -> Self { $x(d) } } impl From<$x> for slotmap::KeyData { - fn from(p : $x) -> Self { + fn from(p: $x) -> Self { p.0 } } diff --git a/src/pieces.rs b/src/pieces.rs index 65c741d4..4adf1cf9 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -100,7 +100,7 @@ pub fn svg_circle_path(diam: f64) -> Html { } #[throws(SE)] -pub fn svg_rectangle_path(PosC([x,y]) : PosC) -> Html { +pub fn svg_rectangle_path(PosC([x,y]): PosC) -> Html { Html(format!("M {} {} h {} v {} h {} z", -x*0.5, -y*0.5, x, y, -x)) } @@ -109,9 +109,9 @@ pub fn svg_rectangle_path(PosC([x,y]) : PosC) -> Html { impl Outline for SimpleShape { delegate! { to self.outline { - fn surround_path(&self, _pri : &PieceRenderInstructions) + fn surround_path(&self, _pri: &PieceRenderInstructions) -> Result; - fn thresh_dragraise(&self, _pri : &PieceRenderInstructions) + fn thresh_dragraise(&self, _pri: &PieceRenderInstructions) -> Result,IE>; fn bbox_approx(&self) -> [Pos;2]; } diff --git a/src/shapelib.rs b/src/shapelib.rs index 9a68bbde..f85ab52a 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -24,7 +24,7 @@ pub struct GroupData { } #[typetag::deserialize(tag="outline")] -pub trait OutlineDefn : Debug + Sync + Send { +pub trait OutlineDefn: Debug + Sync + Send { fn check(&self, lgi: &GroupData) -> Result<(),LLE>; fn load(&self, lgi: &GroupData) -> Result,IE>; } @@ -529,7 +529,7 @@ impl CircleDefn { match group.d.size.as_slice() { &[c] => c, size => throw!(LLE::WrongNumberOfSizeDimensions - { got: size.len(), expected : [1,1] }), + { got: size.len(), expected: [1,1] }), } } } @@ -540,19 +540,19 @@ pub struct Square { pub xy: PosC } #[typetag::serde(name="Square")] impl Outline for Square { #[throws(IE)] - fn surround_path(&self, _pri : &PieceRenderInstructions) -> Html { + fn surround_path(&self, _pri: &PieceRenderInstructions) -> Html { let size = self.xy * SELECT_SCALE; svg_rectangle_path(size)? } #[throws(IE)] - fn thresh_dragraise(&self, _pri : &PieceRenderInstructions) + fn thresh_dragraise(&self, _pri: &PieceRenderInstructions) -> Option { - let smallest : f64 = self.xy.0.iter().cloned() + let smallest: f64 = self.xy.0.iter().cloned() .map(OrderedFloat::from).min().unwrap().into(); Some((smallest * 0.5) as Coord) } fn bbox_approx(&self) -> [Pos;2] { - let pos : Pos = self.xy.map( + let pos: Pos = self.xy.map( |v| ((v * 0.5).ceil()) as Coord ); let neg = -pos; @@ -580,7 +580,7 @@ impl SquareDefn { &[s] => [s,s], s if s.len() == 2 => s.try_into().unwrap(), size => throw!(LLE::WrongNumberOfSizeDimensions - { got: size.len(), expected : [1,2]}), + { got: size.len(), expected: [1,2]}), } )} } diff --git a/src/slotmap-slot-idx.rs b/src/slotmap-slot-idx.rs index fdaf9a14..f0989360 100644 --- a/src/slotmap-slot-idx.rs +++ b/src/slotmap-slot-idx.rs @@ -125,11 +125,11 @@ impl Serializer for &mut MainExtractor { fn serialize_unit (self) -> ROk { u(line!()) } fn serialize_some(self, _: &T) -> ROk - where T : Serialize + ?Sized { u(line!()) } + where T: Serialize + ?Sized { u(line!()) } fn serialize_newtype_struct (self, _:&str, _: &T) -> ROk - where T : Serialize + ?Sized { u(line!()) } + where T: Serialize + ?Sized { u(line!()) } fn serialize_newtype_variant(self, _:&str, _:u32, _:&str, _: &T) -> ROk - where T : Serialize + ?Sized { u(line!()) } + where T: Serialize + ?Sized { u(line!()) } fn serialize_unit_struct (self,_:&str ) -> ROk { u(line!()) } fn serialize_unit_variant(self,_:&str,_:u32,_:&str) -> ROk { u(line!()) } @@ -191,11 +191,11 @@ impl Serializer for ValueExtractor { fn serialize_unit (self) -> R { u(line!()) } fn serialize_some (self, _: &T) -> R - where T : Serialize + ?Sized { u(line!()) } + where T: Serialize + ?Sized { u(line!()) } fn serialize_newtype_struct (self, _:&str, _: &T) -> R - where T : Serialize + ?Sized { u(line!()) } + where T: Serialize + ?Sized { u(line!()) } fn serialize_newtype_variant(self, _:&str, _:u32, _:&str, _: &T) -> R - where T : Serialize + ?Sized { u(line!()) } + where T: Serialize + ?Sized { u(line!()) } fn serialize_unit_struct (self,_:&str ) -> R { u(line!()) } fn serialize_unit_variant (self,_:&str,_:u32,_:&str) -> R { u(line!()) } diff --git a/src/spec.rs b/src/spec.rs index b830c03e..144526b9 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -568,7 +568,7 @@ pub mod implementation { } impl UrlSpec { - const MAX_LEN : usize = 200; + const MAX_LEN: usize = 200; } impl TryFrom<&UrlSpec> for Url { diff --git a/src/sse.rs b/src/sse.rs index 25da9809..ead62d5a 100644 --- a/src/sse.rs +++ b/src/sse.rs @@ -51,7 +51,7 @@ impl UpdateReaderWN { #[throws(io::Error)] fn write_next(&mut self, mut buf: &mut U, tz: &Timezone, next: &PreparedUpdate) - where U : Write { + where U: Write { let tu = next.for_transmit(tz, self.player, self.client); write!(buf, "data: ")?; @@ -226,7 +226,7 @@ impl StableIndexOffset for UpdateId { // ---------- entrypoint for dribbling the http response ---------- #[throws(OE)] -pub fn content(iad : InstanceAccessDetails, gen: Generation) +pub fn content(iad: InstanceAccessDetails, gen: Generation) -> impl Read { let client = iad.ident; @@ -248,13 +248,13 @@ pub fn content(iad : InstanceAccessDetails, gen: Generation) }; UpdateReader { - need_flush : false, - keepalives : Wrapping(0), - overflow : None, + need_flush: false, + keepalives: Wrapping(0), + overflow: None, gref, - ending_send : default(), - init_confirmation_send : iter::once(()), - wn : UpdateReaderWN { + ending_send: default(), + init_confirmation_send: iter::once(()), + wn: UpdateReaderWN { player, client, to_send, }, } diff --git a/src/ui.rs b/src/ui.rs index 3a076d97..c5e3bce8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -4,7 +4,7 @@ use crate::imports::*; -pub const SVG_SCALE : f64 = 6.; +pub const SVG_SCALE: f64 = 6.; pub const HELD_SURROUND_COLOUR: &str = "black"; diff --git a/src/updates.rs b/src/updates.rs index 9bda54b8..5bd3b24e 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -303,7 +303,7 @@ impl PreparedUpdateEntry { impl DataLoadPlayer { pub fn from_player(ig: &Instance, player: PlayerId) -> Self { - let kd : slotmap::KeyData = player.into(); + let kd: slotmap::KeyData = player.into(); let n = kd.get_idx_version().0; let n = if n != 0 { n.try_into().unwrap() } else { ig.gs.players.capacity() }; @@ -524,7 +524,7 @@ impl<'r> PrepareUpdatesBuffer<'r> { } PreparedUpdateEntry_Piece { - by_client : self.by_client, + by_client: self.by_client, ops: out, } } @@ -607,8 +607,9 @@ impl<'r> Drop for PrepareUpdatesBuffer<'r> { type WRC = WhatResponseToClientOp; impl PreparedUpdate { - pub fn for_transmit<'u>(&'u self, tz: &'u Timezone, player: PlayerId, dest : ClientId) - -> TransmitUpdate<'u> { + pub fn for_transmit<'u>(&'u self, tz: &'u Timezone, + player: PlayerId, dest: ClientId) + -> TransmitUpdate<'u> { type ESVU = ErrorSignaledViaUpdate; type PUE = PreparedUpdateEntry; type TUE<'u> = TransmitUpdateEntry<'u>; @@ -729,6 +730,6 @@ impl<'u> Into> for TransmitUpdateLogEntry<'u> { fn serialize_logentry(&(tz,logent): &TransmitUpdateLogEntry, s:S) -> Result { - let f : FormattedLogEntry = (tz, logent).into(); + let f: FormattedLogEntry = (tz, logent).into(); f.serialize(s) } -- 2.30.2