From d3207a8d76c7b6a6283dee36c19c1dac4e378fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Laitl?= Date: Tue, 29 Oct 2024 08:57:37 +0100 Subject: [PATCH] Apply @notgull's suggestion --- src/platform_impl/linux/x11/window.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index 21088593..6e3c551f 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -511,11 +511,13 @@ impl UnownedWindow { None => xconn.default_screen_index() as c_int, }; - let screen_id_usize = usize::try_from(screen_id) - .map_err(|_| NotSupportedError::new("screen id must be non-negative"))?; - let screen = xconn.xcb_connection().setup().roots.get(screen_id_usize).ok_or( - NotSupportedError::new("requested screen id not present in server's response"), - )?; + let screen = { + let screen_id_usize = usize::try_from(screen_id) + .map_err(|_| NotSupportedError::new("screen id must be non-negative"))?; + xconn.xcb_connection().setup().roots.get(screen_id_usize).ok_or( + NotSupportedError::new("requested screen id not present in server's response"), + )? + }; // An iterator over the visuals matching screen id combined with their depths. let mut all_visuals = screen