pub(crate) fn extend(mut self, additions: &str) -> Result<Recipe, (Recipe, String)> {
        // parse and compute differences to current recipe
        let add_rp = match Recipe::from_str(additions, None) {
            Ok(rp) => rp,
            Err(e) => return Err((self, e)),
        };
        let (added, _) = add_rp.compute_delta(&self);

        // move the incorporator state from the old recipe to the new one
        let prior_inc = self.inc.take();

        // build new recipe as clone of old one
        let mut new = Recipe {
            expressions: self.expressions.clone(),
            expression_order: self.expression_order.clone(),
            aliases: self.aliases.clone(),
            version: self.version + 1,
            inc: prior_inc,
            log: self.log.clone(),
            security_config: self.security_config.clone(),
            // retain the old recipe for future reference
            prior: Some(Box::new(self)),
        };

        // apply changes
        for qid in added {
            let q = add_rp.expressions[&qid].clone();
            new.expressions.insert(qid, q);
            new.expression_order.push(qid);
        }

        for (n, qid) in &add_rp.aliases {
            assert!(
                !new.aliases.contains_key(n) || new.aliases[n] == *qid,
                "Query name exists but existing query is different: {}",
                n
            );
        }
        new.aliases.extend(add_rp.aliases);

        // return new recipe as replacement for self
        Ok(new)
    }
/// Append the queries in the `additions` argument to this recipe. This will attempt to parse
/// `additions`, and if successful, will extend the recipe. No expressions are removed from the
/// recipe; use `replace` if removal of unused expressions is desired.
/// Consumes `self` and returns a replacement recipe.
// crate viz for tests
Append the queries in the `additions` argument to this recipe. This will attempt to parse
`additions`, and if successful, will extend the recipe. No expressions are removed from the
recipe; use `replace` if removal of unused expressions is desired.
Consumes `self` and returns a replacement recipe.
crate viz for tests
Append the queries in the ` additions ` argument to this recipe . This will attempt to parse ` additions ` and if successful will extend the recipe . No expressions are removed from the recipe ; use ` replace ` if removal of unused expressions is desired . Consumes ` self ` and returns a replacement recipe . crate viz for tests
pub(crate) fn extend(mut self, additions: &str) -> Result<Recipe, (Recipe, String)> {
        // parse and compute differences to current recipe
        let add_rp = match Recipe::from_str(additions, None) {
            Ok(rp) => rp,
            Err(e) => return Err((self, e)),
        };
        let (added, _) = add_rp.compute_delta(&self);
        // move the incorporator state from the old recipe to the new one
        let prior_inc = self.inc.take();
        // build new recipe as clone of old one
        let mut new = Recipe {
            expressions: self.expressions.clone(),
            expression_order: self.expression_order.clone(),
            aliases: self.aliases.clone(),
            version: self.version + 1,
            inc: prior_inc,
            log: self.log.clone(),
            security_config: self.security_config.clone(),
            // retain the old recipe for future reference
            prior: Some(Box::new(self)),
        };
        // apply changes
        for qid in added {
            let q = add_rp.expressions[&qid].clone();
            new.expressions.insert(qid, q);
            new.expression_order.push(qid);
        }
        for (n, qid) in &add_rp.aliases {
            assert!(
                !new.aliases.contains_key(n) || new.aliases[n] == *qid,
                "Query name exists but existing query is different: {}",
                n
            );
        }
        new.aliases.extend(add_rp.aliases);
        // return new recipe as replacement for self
        Ok(new)
    }
pub ( crate ) fn extend ( mut self , additions : & str ) -> Result < Recipe , ( Recipe , String ) > { // parse and compute differences to current recipe let add_rp = match Recipe :: from_str ( additions , None ) { Ok ( rp ) => rp , Err ( e ) => return Err ( ( self , e ) ) , } ; let ( added , _ ) = add_rp . compute_delta ( & self ) ; // move the incorporator state from the old recipe to the new one let prior_inc = self . inc . take ( ) ; // build new recipe as clone of old one let mut new = Recipe { expressions : self . expressions . clone ( ) , expression_order : self . expression_order . clone ( ) , aliases : self . aliases . clone ( ) , version : self . version + 1 , inc : prior_inc , log : self . log . clone ( ) , security_config : self . security_config . clone ( ) , // retain the old recipe for future reference prior : Some ( Box :: new ( self ) ) , } ; // apply changes for qid in added { let q = add_rp . expressions [ & qid ] . clone ( ) ; new . expressions . insert ( qid , q ) ; new . expression_order . push ( qid ) ; } for ( n , qid ) in & add_rp . aliases { assert ! ( new aliases contains_key ( n ) new aliases [ n ] qid " " n ) ; } new . aliases . extend ( add_rp . aliases ) ; // return new recipe as replacement for self Ok ( new ) }
Append the queries in the `additions` argument to this recipe.
Append the queries in the ` additions ` argument to this recipe .
mut self
additions
&str
mut self
additions
&str