chiark / gitweb /
style: Remove space before :, etc., in src/*.rs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:09:48 +0000 (00:09 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:09:48 +0000 (00:09 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
13 files changed:
src/accounts.rs
src/config.rs
src/error.rs
src/gamestate.rs
src/global.rs
src/keydata.rs
src/pieces.rs
src/shapelib.rs
src/slotmap-slot-idx.rs
src/spec.rs
src/sse.rs
src/ui.rs
src/updates.rs

index 568e3ca6dc117361b7323ee0a8a90f76a15a6184..0a6a925989ac294eb6dcb0aefc70193ee01f41d0 100644 (file)
@@ -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;
index 4d9fd9df5908cdf676b941a853b25f780f94dd04..7fb0bcac833f98499739b9399a7a00b046f32b5a 100644 (file)
@@ -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<ServerConfigSpec> 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
   }
 }
index ce8cc072eb9954a857f713e207b2e563aa575f45..2311f3bdec6cd0adc90de704086bf17264ebc5a9 100644 (file)
@@ -182,14 +182,14 @@ macro_rules! some_slotmap {
 some_slotmap!{DenseSlotMap}
 some_slotmap!{SecondarySlotMap}
 
-impl<T> IdForById for T where T : AccessId {
+impl<T> IdForById for T where T: AccessId {
   type Error = T::Error;
-  const ERROR : Self::Error = <Self as AccessId>::ERROR;
+  const ERROR: Self::Error = <Self as AccessId>::ERROR;
 }
 
 impl IdForById for PieceId {
   type Error = OE;
-  const ERROR : OE = OE::PieceGone;
+  const ERROR: OE = OE::PieceGone;
 }
 
 #[macro_export]
index 883a52abfe62d0bfba3db26fdb681b7ab3727e81..1704761b9b6e056a477aa46a10b41d9611850723 100644 (file)
@@ -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,
index fa8523ed5ac6ab17ad6cdf9b19a190f29783f110..b504cf838ce72162742c8ada4666ba97253f922e 100644 (file)
@@ -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<AccountName>)
                     -> Vec<Arc<InstanceName>> {
     let games = GLOBAL.games_table.read().unwrap();
-    let out : Vec<Arc<InstanceName>> =
+    let out: Vec<Arc<InstanceName>> =
       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<Id:AccessId>(tokens: &mut TokenRegistry<Id>) {
-    let global : &RwLock<TokenTable<Id>> = AccessId::global_tokens(PRIVATE_Y);
+    let global: &RwLock<TokenTable<Id>> = 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<PlayerId, PlayerRecord> = {
+    let iplayers: SecondarySlotMap<PlayerId, PlayerRecord> = {
       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<Id> = HashMap<RawToken, InstanceAccessDetails<Id>>;
 
 pub trait AccessId: Copy + Clone + 'static {
   type Error: Into<OnlineError>;
-  const ERROR : Self::Error;
+  const ERROR: Self::Error;
   fn global_tokens(_:PrivateCaller) -> &'static RwLock<TokenTable<Self>>;
   fn tokens_registry(ig: &mut Instance, _:PrivateCaller)
                      -> &mut TokenRegistry<Self>;
@@ -1226,14 +1226,14 @@ impl RawToken {
   }
 }
 
-pub fn lookup_token<Id : AccessId>(s : &RawTokenVal)
+pub fn lookup_token<Id:AccessId>(s: &RawTokenVal)
       -> Result<InstanceAccessDetails<Id>, Id::Error> {
   Id::global_tokens(PRIVATE_Y).read().unwrap().get(s).cloned()
     .ok_or(Id::ERROR)
 }
 
 #[throws(OE)]
-pub fn record_token<Id : AccessId> (
+pub fn record_token<Id:AccessId> (
   ig: &mut InstanceGuard,
   iad: InstanceAccessDetails<Id>
 ) -> 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 };
index 0853e278d6f5da301c4d3ead0b59ea647bde9c7b..291e91ceec91bfadc12a6408635192baa457006d 100644 (file)
@@ -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<slotmap::KeyData> 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
       }
     }
index 65c741d4f47b24cf34bbadfb5789a2a66109697d..4adf1cf9b43c25dd7689547842952f44b87ce5b6 100644 (file)
@@ -100,7 +100,7 @@ pub fn svg_circle_path(diam: f64) -> Html {
 }
 
 #[throws(SE)]
-pub fn svg_rectangle_path(PosC([x,y]) : PosC<f64>) -> Html {
+pub fn svg_rectangle_path(PosC([x,y]): PosC<f64>) -> 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<f64>) -> Html {
 impl Outline for SimpleShape {
   delegate! {
     to self.outline {
-      fn surround_path(&self, _pri : &PieceRenderInstructions)
+      fn surround_path(&self, _pri: &PieceRenderInstructions)
                        -> Result<Html,IE>;
-      fn thresh_dragraise(&self, _pri : &PieceRenderInstructions)
+      fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)
                           -> Result<Option<Coord>,IE>;
       fn bbox_approx(&self) -> [Pos;2];
     }
index 9a68bbdef420f2e6ace0fc064fdcba754781f814..f85ab52a4efe3e6fdab4f6f87b8624bface1aa89 100644 (file)
@@ -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<Box<dyn Outline>,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<f64> }
 #[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<Coord> {
-    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]}),
       }
     )}
   }
index fdaf9a14cd836642258ba5b33856e17011dbec77..f09893605fe8b6d50da98f019d50647e5040eda3 100644 (file)
@@ -125,11 +125,11 @@ impl Serializer for &mut MainExtractor {
   fn serialize_unit (self)            -> ROk { u(line!()) }
 
   fn serialize_some<T>(self,                                   _: &T) -> ROk
-  where T : Serialize + ?Sized  { u(line!()) }
+  where T: Serialize + ?Sized  { u(line!()) }
   fn serialize_newtype_struct <T>(self, _:&str,                _: &T) -> ROk
-  where T : Serialize + ?Sized  { u(line!()) }
+  where T: Serialize + ?Sized  { u(line!()) }
   fn serialize_newtype_variant<T>(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<V> { u(line!()) }
 
   fn serialize_some           <T>(self,                        _: &T) -> R<V>
-  where T : Serialize + ?Sized  { u(line!()) }
+  where T: Serialize + ?Sized  { u(line!()) }
   fn serialize_newtype_struct <T>(self, _:&str,                _: &T) -> R<V>
-  where T : Serialize + ?Sized  { u(line!()) }
+  where T: Serialize + ?Sized  { u(line!()) }
   fn serialize_newtype_variant<T>(self, _:&str, _:u32, _:&str, _: &T) -> R<V>
-  where T : Serialize + ?Sized  { u(line!()) }
+  where T: Serialize + ?Sized  { u(line!()) }
 
   fn serialize_unit_struct   (self,_:&str             ) -> R<V>    { u(line!()) }
   fn serialize_unit_variant  (self,_:&str,_:u32,_:&str) -> R<V>    { u(line!()) }
index b830c03e64ee9e7e08bdef454bfa030c36410152..144526b92e8e2517dd28ba2cd9716ccc05f93484 100644 (file)
@@ -568,7 +568,7 @@ pub mod implementation {
   }
 
   impl UrlSpec {
-    const MAX_LEN : usize = 200;
+    const MAX_LEN: usize = 200;
   }
 
   impl TryFrom<&UrlSpec> for Url {
index 25da980999f17966b262f1febbc6b30c62525af5..ead62d5aece9795510dfc444bd225165a851469c 100644 (file)
@@ -51,7 +51,7 @@ impl UpdateReaderWN {
   #[throws(io::Error)]
   fn write_next<U>(&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<ClientId>, gen: Generation)
+pub fn content(iad: InstanceAccessDetails<ClientId>, gen: Generation)
   -> impl Read {
   let client = iad.ident;
 
@@ -248,13 +248,13 @@ pub fn content(iad : InstanceAccessDetails<ClientId>, 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,
       },
     }
index 3a076d97083aa8f11f5f6d6b1c9d8e109225d26e..c5e3bce80f9c2d80d1e25c6def55a4666196b8c9 100644 (file)
--- 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";
 
index 9bda54b87fcfdaf01853a908cff1e9111ee43228..5bd3b24e336292b3b07d38cffa33406a2925c7bd 100644 (file)
@@ -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<T> = ErrorSignaledViaUpdate<T>;
     type PUE = PreparedUpdateEntry;
     type TUE<'u> = TransmitUpdateEntry<'u>;
@@ -729,6 +730,6 @@ impl<'u> Into<FormattedLogEntry<'u>> for TransmitUpdateLogEntry<'u> {
 
 fn serialize_logentry<S:Serializer>(&(tz,logent): &TransmitUpdateLogEntry,
                                     s:S) -> Result<S::Ok, S::Error> {
-  let f : FormattedLogEntry = (tz, logent).into();
+  let f: FormattedLogEntry = (tz, logent).into();
   f.serialize(s)
 }