diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs index 8a2a4cdc7..25e2cafe2 100644 --- a/zellij-server/src/os_input_output.rs +++ b/zellij-server/src/os_input_output.rs @@ -580,18 +580,17 @@ impl ServerOsApi for ServerOsInputOutput { .lock() .to_anyhow() .with_context(err_context)?; - let mut terminal_id = None; - { - let current_ids: BTreeSet = self - .terminal_id_to_raw_fd - .lock() - .to_anyhow() - .with_context(err_context)? - .keys() - .copied() - .collect(); - terminal_id = current_ids.last().map(|l| l + 1).or(Some(0)); - } + let terminal_id = self + .terminal_id_to_raw_fd + .lock() + .to_anyhow() + .with_context(err_context)? + .keys() + .copied() + .collect::>() + .last() + .map(|l| l + 1) + .or(Some(0)); match terminal_id { Some(terminal_id) => { self.terminal_id_to_raw_fd @@ -622,18 +621,17 @@ impl ServerOsApi for ServerOsInputOutput { fn reserve_terminal_id(&self) -> Result { let err_context = || "failed to reserve a terminal ID".to_string(); - let mut terminal_id = None; - { - let current_ids: BTreeSet = self - .terminal_id_to_raw_fd - .lock() - .to_anyhow() - .with_context(err_context)? - .keys() - .copied() - .collect(); - terminal_id = current_ids.last().map(|l| l + 1).or(Some(0)); - } + let terminal_id = self + .terminal_id_to_raw_fd + .lock() + .to_anyhow() + .with_context(err_context)? + .keys() + .copied() + .collect::>() + .last() + .map(|l| l + 1) + .or(Some(0)); match terminal_id { Some(terminal_id) => { self.terminal_id_to_raw_fd