fn shift_and_fix(node: Id, depth: i32, best_inventions_of_treenode: &mut AHashMap<Id,NodeCost>, egraph: &mut crate::EGraph) -> Id {
                    let shifted_node = shift(node, -depth, egraph, &mut None).unwrap();
                    if best_inventions_of_treenode.contains_key(&shifted_node) {
                        return shifted_node; // this has already been handled
                    }
                    let mut cloned = best_inventions_of_treenode[&node].clone();
                    // adjust the args needed for the shifted node so that they are shifted too. Note that this
                    // is only safe because we only ever use this for a single invention at a time so this hashtable
                    // actually only has one invention in it. This will be adjusted to be way more clear in the use-conflicts
                    // PR that hasnt yet been merged.
                    // Note that you propagate down the same "depth" for the shift amount for all recursive calls, I think this is correct
                    
                    cloned.inventionful_cost.iter_mut().for_each(|(_key, val)| {
                        if let Some(args) = &mut val.1 {
                            args.iter_mut().for_each(|arg| *arg = shift_and_fix(*arg, depth, best_inventions_of_treenode, egraph));
                        }
                    });
                    best_inventions_of_treenode.insert(shifted_node,cloned);
                    shifted_node
                }
// copy the cost of the unshifted node to the shifted node (see PR#1 comments for why this is safe)
copy the cost of the unshifted node to the shifted node
copy the cost of the unshifted node to the shifted node
fn shift_and_fix(node: Id, depth: i32, best_inventions_of_treenode: &mut AHashMap<Id,NodeCost>, egraph: &mut crate::EGraph) -> Id {
                    let shifted_node = shift(node, -depth, egraph, &mut None).unwrap();
                    if best_inventions_of_treenode.contains_key(&shifted_node) {
                        return shifted_node; // this has already been handled
                    }
                    let mut cloned = best_inventions_of_treenode[&node].clone();
                    // adjust the args needed for the shifted node so that they are shifted too. Note that this
                    // is only safe because we only ever use this for a single invention at a time so this hashtable
                    // actually only has one invention in it. This will be adjusted to be way more clear in the use-conflicts
                    // PR that hasnt yet been merged.
                    // Note that you propagate down the same "depth" for the shift amount for all recursive calls, I think this is correct
                    cloned.inventionful_cost.iter_mut().for_each(|(_key, val)| {
                        if let Some(args) = &mut val.1 {
                            args.iter_mut().for_each(|arg| *arg = shift_and_fix(*arg, depth, best_inventions_of_treenode, egraph));
                        }
                    });
                    best_inventions_of_treenode.insert(shifted_node,cloned);
                    shifted_node
                }
fn shift_and_fix ( node : Id , depth : i32 , best_inventions_of_treenode : & mut AHashMap < Id , NodeCost > , egraph : & mut crate :: EGraph ) -> Id { let shifted_node = shift ( node , - depth , egraph , & mut None ) . unwrap ( ) ; if best_inventions_of_treenode . contains_key ( & shifted_node ) { return shifted_node ; // this has already been handled } let mut cloned = best_inventions_of_treenode [ & node ] . clone ( ) ; // adjust the args needed for the shifted node so that they are shifted too. Note that this // is only safe because we only ever use this for a single invention at a time so this hashtable // actually only has one invention in it. This will be adjusted to be way more clear in the use-conflicts // PR that hasnt yet been merged. // Note that you propagate down the same "depth" for the shift amount for all recursive calls, I think this is correct cloned . inventionful_cost . iter_mut ( ) . for_each ( | ( _key , val ) | { if let Some ( args ) = & mut val . 1 { args . iter_mut ( ) . for_each ( | arg | * arg = shift_and_fix ( * arg , depth , best_inventions_of_treenode , egraph ) ) ; } } ) ; best_inventions_of_treenode . insert ( shifted_node , cloned ) ; shifted_node }
copy the cost of the unshifted node to the shifted node (see PR#1 comments for why this is safe)
copy the cost of the unshifted node to the shifted node ( see PR#1 comments for why this is safe )
node
Id
depth
i32
best_inventions_of_treenode
&mut AHashMap<Id,NodeCost>
egraph
&mut crate::EGraph
node
Id
depth
i32
best_inventions_of_treenode
&mut AHashMap<Id,NodeCost>
egraph
&mut crate::EGraph