pub fn merge(&self, rhs: &EnvMBE<T>) -> EnvMBE<T> {
        let mut res = self.clone();

        let mut rhs_idx_is_named: Vec<bool> = rhs.repeats.iter().map(|_| false).collect();

        // This could be made more efficient by just reusing the `Rc`s instead of cloning the
        // arrays, but that would require reworking the interface.

        for (n, rep_idx) in rhs.named_repeats.iter_pairs() {
            if let Some(rep_idx) = *rep_idx {
                res.add_named_repeat(
                    *n,
                    (*rhs.repeats[rep_idx]).clone(),
                    rhs.ddd_rep_idxes[rep_idx],
                );
                rhs_idx_is_named[rep_idx] = true;
            }
        }

        for (idx, (rep, ddd_rep_idx)) in
            rhs.repeats.iter().zip(rhs.ddd_rep_idxes.iter()).enumerate()
        {
            if !rhs_idx_is_named[idx] {
                res.add_anon_repeat((**rep).clone(), *ddd_rep_idx);
            }
        }

        res.leaves = res.leaves.set_assoc(&rhs.leaves);

        res
    }
/// Combine two `EnvMBE`s whose leaves should be disjoint, but which can contain
/// named repeats with the same name. This should make sense for combining the results of
/// matching two different chunks of a patern.
Combine two `EnvMBE`s whose leaves should be disjoint, but which can contain
named repeats with the same name. This should make sense for combining the results of
matching two different chunks of a patern.
Combine two ` EnvMBE ` s whose leaves should be disjoint but which can contain named repeats with the same name . This should make sense for combining the results of matching two different chunks of a patern .
pub fn merge(&self, rhs: &EnvMBE<T>) -> EnvMBE<T> {
        let mut res = self.clone();
        let mut rhs_idx_is_named: Vec<bool> = rhs.repeats.iter().map(|_| false).collect();
        // This could be made more efficient by just reusing the `Rc`s instead of cloning the
        // arrays, but that would require reworking the interface.
        for (n, rep_idx) in rhs.named_repeats.iter_pairs() {
            if let Some(rep_idx) = *rep_idx {
                res.add_named_repeat(
                    *n,
                    (*rhs.repeats[rep_idx]).clone(),
                    rhs.ddd_rep_idxes[rep_idx],
                );
                rhs_idx_is_named[rep_idx] = true;
            }
        }
        for (idx, (rep, ddd_rep_idx)) in
            rhs.repeats.iter().zip(rhs.ddd_rep_idxes.iter()).enumerate()
        {
            if !rhs_idx_is_named[idx] {
                res.add_anon_repeat((**rep).clone(), *ddd_rep_idx);
            }
        }
        res.leaves = res.leaves.set_assoc(&rhs.leaves);
        res
    }
pub fn merge ( & self , rhs : & EnvMBE < T > ) -> EnvMBE < T > { let mut res = self . clone ( ) ; let mut rhs_idx_is_named : Vec < bool > = rhs . repeats . iter ( ) . map ( | _ | false ) . collect ( ) ; // This could be made more efficient by just reusing the `Rc`s instead of cloning the // arrays, but that would require reworking the interface. for ( n , rep_idx ) in rhs . named_repeats . iter_pairs ( ) { if let Some ( rep_idx ) = * rep_idx { res . add_named_repeat ( * n , ( * rhs . repeats [ rep_idx ] ) . clone ( ) , rhs . ddd_rep_idxes [ rep_idx ] , ) ; rhs_idx_is_named [ rep_idx ] = true ; } } for ( idx , ( rep , ddd_rep_idx ) ) in rhs . repeats . iter ( ) . zip ( rhs . ddd_rep_idxes . iter ( ) ) . enumerate ( ) { if ! rhs_idx_is_named [ idx ] { res . add_anon_repeat ( ( * * rep ) . clone ( ) , * ddd_rep_idx ) ; } } res . leaves = res . leaves . set_assoc ( & rhs . leaves ) ; res }
Combine two `EnvMBE`s whose leaves should be disjoint, but which can contain
named repeats with the same name.
Combine two ` EnvMBE ` s whose leaves should be disjoint but which can contain named repeats with the same name .
&self
rhs
&EnvMBE<T>
&self
rhs
&EnvMBE<T>