pub(crate) fn compile_pat(
        &mut self,
        pat: &ast::Pat,
        false_label: Label,
        load: &dyn Fn(&mut Self, Needs) -> CompileResult<()>,
    ) -> CompileResult<bool> {
        let span = pat.span();
        log::trace!("Pat => {:?}", self.source.source(span));

        match pat {
            ast::Pat::PatPath(path) => {
                let span = path.span();

                let named = self.convert_path_to_named(&path.path)?;

                if let Some(meta) = self.try_lookup_meta(span, &named.item)? {
                    if self.compile_pat_meta_binding(span, &meta, false_label, load)? {
                        return Ok(true);
                    }
                }

                if let Some(ident) = named.as_local() {
                    load(self, Needs::Value)?;
                    self.scopes.decl_var(ident, span)?;
                    return Ok(false);
                }

                Err(CompileError::new(
                    span,
                    CompileErrorKind::UnsupportedBinding,
                ))
            }
            ast::Pat::PatIgnore(..) => {
                // ignore binding, but might still have side effects, so must
                // call the load generator.
                load(self, Needs::None)?;
                Ok(false)
            }
            ast::Pat::PatLit(pat_lit) => Ok(self.compile_pat_lit(pat_lit, false_label, load)?),
            ast::Pat::PatVec(pat_vec) => {
                self.compile_pat_vec(pat_vec, false_label, &load)?;
                Ok(true)
            }
            ast::Pat::PatTuple(pat_tuple) => {
                self.compile_pat_tuple(pat_tuple, false_label, &load)?;
                Ok(true)
            }
            ast::Pat::PatObject(object) => {
                self.compile_pat_object(object, false_label, &load)?;
                Ok(true)
            }
            pat => Err(CompileError::new(
                pat,
                CompileErrorKind::UnsupportedPatternExpr,
            )),
        }
    }
/// Encode a pattern.
///
/// Patterns will clean up their own locals and execute a jump to
/// `false_label` in case the pattern does not match.
///
/// Returns a boolean indicating if the label was used.
Encode a pattern.
Patterns will clean up their own locals and execute a jump to
`false_label` in case the pattern does not match.

Returns a boolean indicating if the label was used.
Encode a pattern . Patterns will clean up their own locals and execute a jump to ` false_label ` in case the pattern does not match . Returns a boolean indicating if the label was used .
pub(crate) fn compile_pat(
        &mut self,
        pat: &ast::Pat,
        false_label: Label,
        load: &dyn Fn(&mut Self, Needs) -> CompileResult<()>,
    ) -> CompileResult<bool> {
        let span = pat.span();
        log::trace!("Pat => {:?}", self.source.source(span));
        match pat {
            ast::Pat::PatPath(path) => {
                let span = path.span();
                let named = self.convert_path_to_named(&path.path)?;
                if let Some(meta) = self.try_lookup_meta(span, &named.item)? {
                    if self.compile_pat_meta_binding(span, &meta, false_label, load)? {
                        return Ok(true);
                    }
                }
                if let Some(ident) = named.as_local() {
                    load(self, Needs::Value)?;
                    self.scopes.decl_var(ident, span)?;
                    return Ok(false);
                }
                Err(CompileError::new(
                    span,
                    CompileErrorKind::UnsupportedBinding,
                ))
            }
            ast::Pat::PatIgnore(..) => {
                // ignore binding, but might still have side effects, so must
                // call the load generator.
                load(self, Needs::None)?;
                Ok(false)
            }
            ast::Pat::PatLit(pat_lit) => Ok(self.compile_pat_lit(pat_lit, false_label, load)?),
            ast::Pat::PatVec(pat_vec) => {
                self.compile_pat_vec(pat_vec, false_label, &load)?;
                Ok(true)
            }
            ast::Pat::PatTuple(pat_tuple) => {
                self.compile_pat_tuple(pat_tuple, false_label, &load)?;
                Ok(true)
            }
            ast::Pat::PatObject(object) => {
                self.compile_pat_object(object, false_label, &load)?;
                Ok(true)
            }
            pat => Err(CompileError::new(
                pat,
                CompileErrorKind::UnsupportedPatternExpr,
            )),
        }
    }
pub ( crate ) fn compile_pat ( & mut self , pat : & ast :: Pat , false_label : Label , load : & dyn Fn ( & mut Self , Needs ) -> CompileResult < ( ) > , ) -> CompileResult < bool > { let span = pat . span ( ) ; log :: trace ! ( " " self source source ( span ) ) ; match pat { ast :: Pat :: PatPath ( path ) => { let span = path . span ( ) ; let named = self . convert_path_to_named ( & path . path ) ? ; if let Some ( meta ) = self . try_lookup_meta ( span , & named . item ) ? { if self . compile_pat_meta_binding ( span , & meta , false_label , load ) ? { return Ok ( true ) ; } } if let Some ( ident ) = named . as_local ( ) { load ( self , Needs :: Value ) ? ; self . scopes . decl_var ( ident , span ) ? ; return Ok ( false ) ; } Err ( CompileError :: new ( span , CompileErrorKind :: UnsupportedBinding , ) ) } ast :: Pat :: PatIgnore ( .. ) => { // ignore binding, but might still have side effects, so must // call the load generator. load ( self , Needs :: None ) ? ; Ok ( false ) } ast :: Pat :: PatLit ( pat_lit ) => Ok ( self . compile_pat_lit ( pat_lit , false_label , load ) ? ) , ast :: Pat :: PatVec ( pat_vec ) => { self . compile_pat_vec ( pat_vec , false_label , & load ) ? ; Ok ( true ) } ast :: Pat :: PatTuple ( pat_tuple ) => { self . compile_pat_tuple ( pat_tuple , false_label , & load ) ? ; Ok ( true ) } ast :: Pat :: PatObject ( object ) => { self . compile_pat_object ( object , false_label , & load ) ? ; Ok ( true ) } pat => Err ( CompileError :: new ( pat , CompileErrorKind :: UnsupportedPatternExpr , ) ) , } }
Encode a pattern.
Encode a pattern .
&mut self
pat
&ast::Pat
false_label
Label
load
&dyn Fn(&mut Self, Needs) -> CompileResult<()>
&mut self
pat
&ast::Pat
false_label
Label
load
&dyn Fn(&mut Self, Needs) -> CompileResult<()>