pub fn matches(&self, other: &ShaderInterface) -> Result<(), ShaderInterfaceMismatchError> {
        if self.elements().len() != other.elements().len() {
            return Err(ShaderInterfaceMismatchError::ElementsCountMismatch {
                self_elements: self.elements().len() as u32,
                other_elements: other.elements().len() as u32,
            });
        }

        for a in self.elements() {
            let location_range = a.location..a.location + a.ty.num_locations();
            for loc in location_range {
                let b = match other
                    .elements()
                    .iter()
                    .find(|e| loc >= e.location && loc < e.location + e.ty.num_locations())
                {
                    None => {
                        return Err(ShaderInterfaceMismatchError::MissingElement { location: loc })
                    }
                    Some(b) => b,
                };

                if a.ty != b.ty {
                    return Err(ShaderInterfaceMismatchError::TypeMismatch {
                        location: loc,
                        self_ty: a.ty,
                        other_ty: b.ty,
                    });
                }

                // TODO: enforce this?
                /*match (a.name, b.name) {
                    (Some(ref an), Some(ref bn)) => if an != bn { return false },
                    _ => ()
                };*/
            }
        }

        // Note: since we check that the number of elements is the same, we don't need to iterate
        // over b's elements.

        Ok(())
    }
/// Checks whether the interface is potentially compatible with another one.
///
/// Returns `Ok` if the two interfaces are compatible.
Checks whether the interface is potentially compatible with another one.
Returns `Ok` if the two interfaces are compatible.
Checks whether the interface is potentially compatible with another one . Returns ` Ok ` if the two interfaces are compatible .
pub fn matches(&self, other: &ShaderInterface) -> Result<(), ShaderInterfaceMismatchError> {
        if self.elements().len() != other.elements().len() {
            return Err(ShaderInterfaceMismatchError::ElementsCountMismatch {
                self_elements: self.elements().len() as u32,
                other_elements: other.elements().len() as u32,
            });
        }
        for a in self.elements() {
            let location_range = a.location..a.location + a.ty.num_locations();
            for loc in location_range {
                let b = match other
                    .elements()
                    .iter()
                    .find(|e| loc >= e.location && loc < e.location + e.ty.num_locations())
                {
                    None => {
                        return Err(ShaderInterfaceMismatchError::MissingElement { location: loc })
                    }
                    Some(b) => b,
                };
                if a.ty != b.ty {
                    return Err(ShaderInterfaceMismatchError::TypeMismatch {
                        location: loc,
                        self_ty: a.ty,
                        other_ty: b.ty,
                    });
                }
                // TODO: enforce this?
                /*match (a.name, b.name) {
                    (Some(ref an), Some(ref bn)) => if an != bn { return false },
                    _ => ()
                };*/
            }
        }
        // Note: since we check that the number of elements is the same, we don't need to iterate
        // over b's elements.
        Ok(())
    }
pub fn matches ( & self , other : & ShaderInterface ) -> Result < ( ) , ShaderInterfaceMismatchError > { if self . elements ( ) . len ( ) != other . elements ( ) . len ( ) { return Err ( ShaderInterfaceMismatchError :: ElementsCountMismatch { self_elements : self . elements ( ) . len ( ) as u32 , other_elements : other . elements ( ) . len ( ) as u32 , } ) ; } for a in self . elements ( ) { let location_range = a . location .. a . location + a . ty . num_locations ( ) ; for loc in location_range { let b = match other . elements ( ) . iter ( ) . find ( | e | loc >= e . location && loc < e . location + e . ty . num_locations ( ) ) { None => { return Err ( ShaderInterfaceMismatchError :: MissingElement { location : loc } ) } Some ( b ) => b , } ; if a . ty != b . ty { return Err ( ShaderInterfaceMismatchError :: TypeMismatch { location : loc , self_ty : a . ty , other_ty : b . ty , } ) ; } // TODO: enforce this? /*match (a.name, b.name) {
                    (Some(ref an), Some(ref bn)) => if an != bn { return false },
                    _ => ()
                };*/ } } // Note: since we check that the number of elements is the same, we don't need to iterate // over b's elements. Ok ( ( ) ) }
Checks whether the interface is potentially compatible with another one.
Checks whether the interface is potentially compatible with another one .
&self
other
&ShaderInterface
&self
other
&ShaderInterface