chiark / gitweb /
Change many .drain(..) into into_iter()
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 10:35:33 +0000 (11:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 10:37:13 +0000 (11:37 +0100)
In Rust 2021 this is more convenient to write.  We retain one.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/global.rs

index 53f95a30130e01143113289916b442180312462f..11da90edcbd2b537b40495980f907005f85a3967 100644 (file)
@@ -789,6 +789,7 @@ impl<'ig> InstanceGuard<'ig> {
 
     self.save_game_now().map_err(|e|{
       // oof
+      #[allow(clippy::iter_with_drain)] // don't eat undo, so we can drop it
       for u in undo.drain(..).rev() {
         u(self);
       }
@@ -1237,7 +1238,7 @@ impl InstanceGuard<'_> {
     }
 
     let name = Arc::new(name);
-    let (mut tokens_players, acctids_players) = {
+    let (tokens_players, acctids_players) = {
       let mut tokens = Vec::with_capacity(tokens_players.len());
       let mut acctids = Vec::with_capacity(tokens_players.len());
       for (token, player) in tokens_players { if_chain! {
@@ -1291,7 +1292,7 @@ impl InstanceGuard<'_> {
     }
     let mut global = GLOBAL.players.write();
     for ((token, player), acctid) in
-      tokens_players.drain(0..)
+      tokens_players.into_iter()
       .zip(acctids_players)
     { if_chain!{
       if let Some(acctid) = acctid;
@@ -1586,7 +1587,7 @@ fn client_expire_old_clients() {
       expire.push(gref.clone());
     }
   }
-  for gref in expire.drain(..) {
+  for gref in expire.into_iter() {
     #[derive(Debug)]
     struct Now(HashSet<ClientId>);
     impl ClientIterator for Now {
@@ -1628,7 +1629,7 @@ fn global_expire_old_logs() {
   }
   drop(read);
 
-  for gref in want_expire.drain(..) {
+  for gref in want_expire.into_iter() {
     let mut g = gref.lock_even_destroying();
     info!("expiring old log entries in {:?}", &g.g.name);
     g.g.gs.do_expire_old_logs(cutoff);