reflect: replace let_chains with Option::filter

This commit is contained in:
chyyran 2024-09-14 01:51:00 -04:00 committed by Ronny Chan
parent 3d9139b4e0
commit 8b2ff57ee8
3 changed files with 24 additions and 13 deletions

View file

@ -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.

View file

@ -383,8 +383,10 @@ where
UniqueSemantics::FloatParameter => {
let offset = range.offset;
if let Some(meta) = meta.parameter_meta.get_mut::<str>(&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(),

View file

@ -679,8 +679,10 @@ impl NagaReflect {
UniqueSemantics::FloatParameter => {
let offset = member.offset;
if let Some(meta) = meta.parameter_meta.get_mut::<str>(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,