From 8b2ff57ee8810581015103d8f318899cdc4d520d Mon Sep 17 00:00:00 2001 From: chyyran Date: Sat, 14 Sep 2024 01:51:00 -0400 Subject: [PATCH] reflect: replace `let_chains` with `Option::filter` --- librashader-reflect/src/lib.rs | 1 - librashader-reflect/src/reflect/cross/mod.rs | 18 ++++++++++++------ librashader-reflect/src/reflect/naga/mod.rs | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/librashader-reflect/src/lib.rs b/librashader-reflect/src/lib.rs index bbae1c7..65a5224 100644 --- a/librashader-reflect/src/lib.rs +++ b/librashader-reflect/src/lib.rs @@ -44,7 +44,6 @@ //! a pure-Rust shader compiler, as well as SPIRV-Cross via [SpirvCompilation](crate::front::SpirvCompilation) //! is supported. #![feature(impl_trait_in_assoc_type)] -#![feature(let_chains)] #![allow(stable_features)] #![feature(c_str_literals)] /// Shader codegen backends. diff --git a/librashader-reflect/src/reflect/cross/mod.rs b/librashader-reflect/src/reflect/cross/mod.rs index d19da76..8f4ef4a 100644 --- a/librashader-reflect/src/reflect/cross/mod.rs +++ b/librashader-reflect/src/reflect/cross/mod.rs @@ -383,8 +383,10 @@ where UniqueSemantics::FloatParameter => { let offset = range.offset; if let Some(meta) = meta.parameter_meta.get_mut::(&name.as_ref()) { - if let Some(expected) = meta.offset.offset(offset_type) - && expected != offset + if let Some(expected) = meta + .offset + .offset(offset_type) + .filter(|expected| *expected != offset) { return Err(ShaderReflectError::MismatchedOffset { semantic: name.to_string(), @@ -419,8 +421,10 @@ where semantics => { let offset = range.offset; if let Some(meta) = meta.unique_meta.get_mut(semantics) { - if let Some(expected) = meta.offset.offset(offset_type) - && expected != offset + if let Some(expected) = meta + .offset + .offset(offset_type) + .filter(|expected| *expected != offset) { return Err(ShaderReflectError::MismatchedOffset { semantic: name.to_string(), @@ -470,8 +474,10 @@ where let offset = range.offset; if let Some(meta) = meta.texture_size_meta.get_mut(&texture) { - if let Some(expected) = meta.offset.offset(offset_type) - && expected != offset + if let Some(expected) = meta + .offset + .offset(offset_type) + .filter(|expected| *expected != offset) { return Err(ShaderReflectError::MismatchedOffset { semantic: name.to_string(), diff --git a/librashader-reflect/src/reflect/naga/mod.rs b/librashader-reflect/src/reflect/naga/mod.rs index 273c0fa..cdd1ca3 100644 --- a/librashader-reflect/src/reflect/naga/mod.rs +++ b/librashader-reflect/src/reflect/naga/mod.rs @@ -679,8 +679,10 @@ impl NagaReflect { UniqueSemantics::FloatParameter => { let offset = member.offset; if let Some(meta) = meta.parameter_meta.get_mut::(name.as_ref()) { - if let Some(expected) = meta.offset.offset(offset_type) - && expected != offset as usize + if let Some(expected) = meta + .offset + .offset(offset_type) + .filter(|expected| *expected != offset as usize) { return Err(ShaderReflectError::MismatchedOffset { semantic: name, @@ -715,8 +717,10 @@ impl NagaReflect { semantics => { let offset = member.offset; if let Some(meta) = meta.unique_meta.get_mut(semantics) { - if let Some(expected) = meta.offset.offset(offset_type) - && expected != offset as usize + if let Some(expected) = meta + .offset + .offset(offset_type) + .filter(|expected| *expected != offset as usize) { return Err(ShaderReflectError::MismatchedOffset { semantic: name, @@ -764,8 +768,10 @@ impl NagaReflect { let offset = member.offset; if let Some(meta) = meta.texture_size_meta.get_mut(&texture) { - if let Some(expected) = meta.offset.offset(offset_type) - && expected != offset as usize + if let Some(expected) = meta + .offset + .offset(offset_type) + .filter(|expected| *expected != offset as usize) { return Err(ShaderReflectError::MismatchedOffset { semantic: name,