pub(crate) fn compile_pat_meta_binding(
        &mut self,
        span: Span,
        meta: &CompileMeta,
        false_label: Label,
        load: &dyn Fn(&mut Self, Needs) -> CompileResult<()>,
    ) -> CompileResult<bool> {
        let type_check = match &meta.kind {
            CompileMetaKind::UnitStruct { type_hash, .. } => TypeCheck::Type(*type_hash),
            CompileMetaKind::TupleStruct {
                tuple, type_hash, ..
            } if tuple.args == 0 => TypeCheck::Type(*type_hash),
            CompileMetaKind::UnitVariant { type_hash, .. } => TypeCheck::Variant(*type_hash),
            CompileMetaKind::TupleVariant {
                tuple, type_hash, ..
            } if tuple.args == 0 => TypeCheck::Variant(*type_hash),
            _ => return Ok(false),
        };

        let type_check = match self.context.type_check_for(&meta.item.item) {
            Some(type_check) => type_check,
            None => type_check,
        };

        load(self, Needs::Value)?;
        self.asm.push(
            Inst::MatchSequence {
                type_check,
                len: 0,
                exact: true,
            },
            span,
        );
        self.asm
            .pop_and_jump_if_not(self.scopes.local_var_count(span)?, false_label, span);
        Ok(true)
    }
/// Compile a binding name that matches a known meta type.
///
/// Returns `true` if the binding was used.
Compile a binding name that matches a known meta type.
Returns `true` if the binding was used.
Compile a binding name that matches a known meta type . Returns ` true ` if the binding was used .
pub(crate) fn compile_pat_meta_binding(
        &mut self,
        span: Span,
        meta: &CompileMeta,
        false_label: Label,
        load: &dyn Fn(&mut Self, Needs) -> CompileResult<()>,
    ) -> CompileResult<bool> {
        let type_check = match &meta.kind {
            CompileMetaKind::UnitStruct { type_hash, .. } => TypeCheck::Type(*type_hash),
            CompileMetaKind::TupleStruct {
                tuple, type_hash, ..
            } if tuple.args == 0 => TypeCheck::Type(*type_hash),
            CompileMetaKind::UnitVariant { type_hash, .. } => TypeCheck::Variant(*type_hash),
            CompileMetaKind::TupleVariant {
                tuple, type_hash, ..
            } if tuple.args == 0 => TypeCheck::Variant(*type_hash),
            _ => return Ok(false),
        };
        let type_check = match self.context.type_check_for(&meta.item.item) {
            Some(type_check) => type_check,
            None => type_check,
        };
        load(self, Needs::Value)?;
        self.asm.push(
            Inst::MatchSequence {
                type_check,
                len: 0,
                exact: true,
            },
            span,
        );
        self.asm
            .pop_and_jump_if_not(self.scopes.local_var_count(span)?, false_label, span);
        Ok(true)
    }
pub ( crate ) fn compile_pat_meta_binding ( & mut self , span : Span , meta : & CompileMeta , false_label : Label , load : & dyn Fn ( & mut Self , Needs ) -> CompileResult < ( ) > , ) -> CompileResult < bool > { let type_check = match & meta . kind { CompileMetaKind :: UnitStruct { type_hash , .. } => TypeCheck :: Type ( * type_hash ) , CompileMetaKind :: TupleStruct { tuple , type_hash , .. } if tuple . args == 0 => TypeCheck :: Type ( * type_hash ) , CompileMetaKind :: UnitVariant { type_hash , .. } => TypeCheck :: Variant ( * type_hash ) , CompileMetaKind :: TupleVariant { tuple , type_hash , .. } if tuple . args == 0 => TypeCheck :: Variant ( * type_hash ) , _ => return Ok ( false ) , } ; let type_check = match self . context . type_check_for ( & meta . item . item ) { Some ( type_check ) => type_check , None => type_check , } ; load ( self , Needs :: Value ) ? ; self . asm . push ( Inst :: MatchSequence { type_check , len : 0 , exact : true , } , span , ) ; self . asm . pop_and_jump_if_not ( self . scopes . local_var_count ( span ) ? , false_label , span ) ; Ok ( true ) }
Compile a binding name that matches a known meta type.
Compile a binding name that matches a known meta type .
&mut self
span
Span
meta
&CompileMeta
false_label
Label
load
&dyn Fn(&mut Self, Needs) -> CompileResult<()>
&mut self
span
Span
meta
&CompileMeta
false_label
Label
load
&dyn Fn(&mut Self, Needs) -> CompileResult<()>