rt(gl): use Option::filter instead of let_chains

This commit is contained in:
chyyran 2024-09-13 18:10:55 -04:00 committed by Ronny Chan
parent 0ba4c482b3
commit ab9ab6fe68
3 changed files with 11 additions and 11 deletions

View file

@ -69,8 +69,9 @@ where
location: VariableLocation, location: VariableLocation,
_: &(), _: &(),
) -> Option<()> { ) -> Option<()> {
if let Some(location) = location.location(block) if let Some(location) = location
&& location.bindable() .location(block)
.filter(|location| location.bindable())
{ {
if location.is_valid(BindingStage::VERTEX) { if location.is_valid(BindingStage::VERTEX) {
unsafe { unsafe {
@ -96,8 +97,9 @@ impl BindUniform<VariableLocation, &[f32; 4], ()> for GlUniformBinder {
location: VariableLocation, location: VariableLocation,
_: &(), _: &(),
) -> Option<()> { ) -> Option<()> {
if let Some(location) = location.location(block) if let Some(location) = location
&& location.bindable() .location(block)
.filter(|location| location.bindable())
{ {
unsafe { unsafe {
if location.is_valid(BindingStage::VERTEX) { if location.is_valid(BindingStage::VERTEX) {
@ -121,8 +123,9 @@ impl BindUniform<VariableLocation, &[f32; 16], ()> for GlUniformBinder {
location: VariableLocation, location: VariableLocation,
_: &(), _: &(),
) -> Option<()> { ) -> Option<()> {
if let Some(location) = location.location(block) if let Some(location) = location
&& location.bindable() .location(block)
.filter(|location| location.bindable())
{ {
unsafe { unsafe {
if location.is_valid(BindingStage::VERTEX) { if location.is_valid(BindingStage::VERTEX) {

View file

@ -28,12 +28,10 @@ impl FilterChainGL {
options: Option<&FilterChainOptionsGL>, options: Option<&FilterChainOptionsGL>,
) -> Result<Self> { ) -> Result<Self> {
let result = catch_unwind(|| { let result = catch_unwind(|| {
if let Some(options) = options if options.is_some_and(|options| options.use_dsa) {
&& options.use_dsa
{
return Ok(Self { return Ok(Self {
filter: FilterChainDispatch::DirectStateAccess(unsafe { filter: FilterChainDispatch::DirectStateAccess(unsafe {
FilterChainImpl::load_from_preset(preset, Some(options))? FilterChainImpl::load_from_preset(preset, options)?
}), }),
}); });
} }

View file

@ -3,7 +3,6 @@
//! This crate should not be used directly. //! This crate should not be used directly.
//! See [`librashader::runtime::gl`](https://docs.rs/librashader/latest/librashader/runtime/gl/index.html) instead. //! See [`librashader::runtime::gl`](https://docs.rs/librashader/latest/librashader/runtime/gl/index.html) instead.
#![deny(unsafe_op_in_unsafe_fn)] #![deny(unsafe_op_in_unsafe_fn)]
#![feature(let_chains)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
mod binding; mod binding;