diff --git a/wayland-client/src/globals.rs b/wayland-client/src/globals.rs index dc897a3edfc..4054d62111e 100644 --- a/wayland-client/src/globals.rs +++ b/wayland-client/src/globals.rs @@ -155,20 +155,14 @@ impl GlobalList { let (name, version) = guard .iter() // Find the with the correct interface - .filter_map(|Global { name, interface: interface_name, version }| { - // TODO: then_some - if interface.name == &interface_name[..] { - Some((*name, *version)) - } else { - None - } + .find_map(|Global { name, interface: interface_name, version }| { + (interface.name == &interface_name[..]).then_some((*name, *version)) }) - .next() .ok_or(BindError::NotPresent)?; // Test version requirements if version < version_start { - return Err(BindError::UnsupportedVersion); + return Err(BindError::UnsupportedVersion(version)); } // To get the version to bind, take the lower of the version advertised by the server and the maximum @@ -232,7 +226,7 @@ impl From for GlobalError { #[derive(Debug)] pub enum BindError { /// The requested version of the global is not supported. - UnsupportedVersion, + UnsupportedVersion(u32), /// The requested global was not found in the registry. NotPresent, @@ -243,8 +237,8 @@ impl std::error::Error for BindError {} impl fmt::Display for BindError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - BindError::UnsupportedVersion {} => { - write!(f, "the requested version of the global is not supported") + BindError::UnsupportedVersion(version) => { + write!(f, "the available version {version} of the global is lower than the requested version") } BindError::NotPresent {} => { write!(f, "the requested global was not found in the registry")