fn select<'a>(
    d1: &'a DiffGraph<'_>,
    d2: &'a DiffGraph<'_>,
    n: &'a str,
    list_of_labs: &[&'a str],
    use_text_dist_filter: bool,
) -> Option<&'a str> {
    let node = d1.graph.get_node_by_label(n).unwrap();
    let node_content = &node.content;
    // TODO: Find a better measure
    // maybe count the </br>s and <tr>s?
    let content_len = node.get_content_length();
    list_of_labs
        .iter()
        // FIXME: investigate whether this is a useful filter
        // .filter(|lab| {
        //     if !use_text_dist_filter {
        //         return true;
        //     }
        //     let other_node = d2.graph.get_node_by_label(lab).unwrap();
        //     // filter out nodes that may differ by more than 2 lines
        //     (other_node.stmts.len() as i64 - node.stmts.len() as i64).abs() <= 2
        // })
        .filter(|lab| {
            if !use_text_dist_filter {
                return true;
            }
            let other_node_content = &d2.graph.get_node_by_label(lab).unwrap().content;
            // allow bigger blocks have more edits
            // 2 here is arbitary
            distance(&node_content, &other_node_content) < 2 * content_len
        })
        .min_by_key(|x| dist_bw_nodes(d1, d2, n, x))
        .map(|x| *x)
}
/// Selects the most suitable match for n from L
Selects the most suitable match for n from L
Selects the most suitable match for n from L
fn select<'a>(
    d1: &'a DiffGraph<'_>,
    d2: &'a DiffGraph<'_>,
    n: &'a str,
    list_of_labs: &[&'a str],
    use_text_dist_filter: bool,
) -> Option<&'a str> {
    let node = d1.graph.get_node_by_label(n).unwrap();
    let node_content = &node.content;
    // TODO: Find a better measure
    // maybe count the </br>s and <tr>s?
    let content_len = node.get_content_length();
    list_of_labs
        .iter()
        // FIXME: investigate whether this is a useful filter
        // .filter(|lab| {
        //     if !use_text_dist_filter {
        //         return true;
        //     }
        //     let other_node = d2.graph.get_node_by_label(lab).unwrap();
        //     // filter out nodes that may differ by more than 2 lines
        //     (other_node.stmts.len() as i64 - node.stmts.len() as i64).abs() <= 2
        // })
        .filter(|lab| {
            if !use_text_dist_filter {
                return true;
            }
            let other_node_content = &d2.graph.get_node_by_label(lab).unwrap().content;
            // allow bigger blocks have more edits
            // 2 here is arbitary
            distance(&node_content, &other_node_content) < 2 * content_len
        })
        .min_by_key(|x| dist_bw_nodes(d1, d2, n, x))
        .map(|x| *x)
}
fn select < ' a > ( d1 : & ' a DiffGraph < ' _ > , d2 : & ' a DiffGraph < ' _ > , n : & ' a str , list_of_labs : & [ & ' a str ] , use_text_dist_filter : bool , ) -> Option < & ' a str > { let node = d1 . graph . get_node_by_label ( n ) . unwrap ( ) ; let node_content = & node . content ; // TODO: Find a better measure // maybe count the </br>s and <tr>s? let content_len = node . get_content_length ( ) ; list_of_labs . iter ( ) // FIXME: investigate whether this is a useful filter // .filter(|lab| { //     if !use_text_dist_filter { //         return true; //     } //     let other_node = d2.graph.get_node_by_label(lab).unwrap(); //     // filter out nodes that may differ by more than 2 lines //     (other_node.stmts.len() as i64 - node.stmts.len() as i64).abs() <= 2 // }) . filter ( | lab | { if ! use_text_dist_filter { return true ; } let other_node_content = & d2 . graph . get_node_by_label ( lab ) . unwrap ( ) . content ; // allow bigger blocks have more edits // 2 here is arbitary distance ( & node_content , & other_node_content ) < 2 * content_len } ) . min_by_key ( | x | dist_bw_nodes ( d1 , d2 , n , x ) ) . map ( | x | * x ) }
Selects the most suitable match for n from L
Selects the most suitable match for n from L
d1
&'a DiffGraph<'_>
d2
&'a DiffGraph<'_>
n
&'a str
list_of_labs
&[&'a str]
use_text_dist_filter
bool
d1
&'a DiffGraph<'_>
d2
&'a DiffGraph<'_>
n
&'a str
list_of_labs
&[&'a str]
use_text_dist_filter
bool