pub(super) fn dedup_links(links: &mut Vec<Link>) {
    // The indices of links which are special cases of some other link (or are identical to other
    // links)
    let mut redundant_link_idxs = Vec::<usize>::new();
    for (i, link) in links.iter().enumerate() {
        for (i2, link2) in links.iter().enumerate() {
            // Links are always compatible with themselves, and there's no point 'de-duplicating' a
            // link because it's redundant against itself
            if i == i2 {
                continue;
            }

            // This is 'true' if `link` and `link2` are equal apart from their course head masks.
            // We don't check the names, since it's possible that the same link is given two
            // different names (e.g. near near would generate `pI` and `pT` which should be
            // considered identical).  If the links do have different names, then one of them is
            // picked arbitrarily.
            let are_links_otherwise_equal = link.eq_without_name_or_ch_mask(link2);

            if are_links_otherwise_equal {
                if link.ch_mask == link2.ch_mask {
                    // If the links are identical, then we remove the one with the least index.
                    // This way, exactly one link from a group of identical links (the one with the
                    // highest index) will survive
                    if i < i2 {
                        redundant_link_idxs.push(i);
                    }
                } else if link.ch_mask.is_subset_of(&link2.ch_mask) {
                    // If `link2`'s CH mask is more general than `link`'s, and `link` and `link2`
                    // are otherwise equal, then `link` is a special case of `link2` and is
                    // therefore redundant
                    redundant_link_idxs.push(i);
                }
            }
        }
    }

    // Now actually remove the unnecessary links, making sure to iterate backwards so that the
    // indices keep pointing to the right elements
    redundant_link_idxs.sort_unstable();
    redundant_link_idxs.dedup();
    for idx in redundant_link_idxs.into_iter().rev() {
        links.remove(idx);
    }
}
/// Remove any [`Link`]s which are equal to another [`Link`] (ignoring names).
///
/// This is required because [`generate_all_links`] creates a large number of identical plain call
/// links if there are multiple calls at the same position (which there almost always are).
///
/// This doesn't always actually lead to the generation of duplicate compositions (because there
/// could be two identical calls with different but compatible course head masks), so the graph
/// generation code has to perform de-duplication regardless.  However, de-duplication makes the
/// code both more performant and, more importantly, makes the resulting [`Layout`]s easier to
/// debug.
Remove any [`Link`]s which are equal to another [`Link`] (ignoring names).
This is required because [`generate_all_links`] creates a large number of identical plain call
links if there are multiple calls at the same position (which there almost always are).

This doesn't always actually lead to the generation of duplicate compositions (because there
could be two identical calls with different but compatible course head masks), so the graph
generation code has to perform de-duplication regardless.  However, de-duplication makes the
code both more performant and, more importantly, makes the resulting [`Layout`]s easier to
debug.
Remove any [ ` Link ` ] s which are equal to another [ ` Link ` ] ( ignoring names ) . This is required because [ ` generate_all_links ` ] creates a large number of identical plain call links if there are multiple calls at the same position ( which there almost always are ) . This doesn ' t always actually lead to the generation of duplicate compositions ( because there could be two identical calls with different but compatible course head masks ) so the graph generation code has to perform de - duplication regardless . However de - duplication makes the code both more performant and more importantly makes the resulting [ ` Layout ` ] s easier to debug .
pub(super) fn dedup_links(links: &mut Vec<Link>) {
    // The indices of links which are special cases of some other link (or are identical to other
    // links)
    let mut redundant_link_idxs = Vec::<usize>::new();
    for (i, link) in links.iter().enumerate() {
        for (i2, link2) in links.iter().enumerate() {
            // Links are always compatible with themselves, and there's no point 'de-duplicating' a
            // link because it's redundant against itself
            if i == i2 {
                continue;
            }
            // This is 'true' if `link` and `link2` are equal apart from their course head masks.
            // We don't check the names, since it's possible that the same link is given two
            // different names (e.g. near near would generate `pI` and `pT` which should be
            // considered identical).  If the links do have different names, then one of them is
            // picked arbitrarily.
            let are_links_otherwise_equal = link.eq_without_name_or_ch_mask(link2);
            if are_links_otherwise_equal {
                if link.ch_mask == link2.ch_mask {
                    // If the links are identical, then we remove the one with the least index.
                    // This way, exactly one link from a group of identical links (the one with the
                    // highest index) will survive
                    if i < i2 {
                        redundant_link_idxs.push(i);
                    }
                } else if link.ch_mask.is_subset_of(&link2.ch_mask) {
                    // If `link2`'s CH mask is more general than `link`'s, and `link` and `link2`
                    // are otherwise equal, then `link` is a special case of `link2` and is
                    // therefore redundant
                    redundant_link_idxs.push(i);
                }
            }
        }
    }
    // Now actually remove the unnecessary links, making sure to iterate backwards so that the
    // indices keep pointing to the right elements
    redundant_link_idxs.sort_unstable();
    redundant_link_idxs.dedup();
    for idx in redundant_link_idxs.into_iter().rev() {
        links.remove(idx);
    }
}
pub ( super ) fn dedup_links ( links : & mut Vec < Link > ) { // The indices of links which are special cases of some other link (or are identical to other // links) let mut redundant_link_idxs = Vec :: < usize > :: new ( ) ; for ( i , link ) in links . iter ( ) . enumerate ( ) { for ( i2 , link2 ) in links . iter ( ) . enumerate ( ) { // Links are always compatible with themselves, and there's no point 'de-duplicating' a // link because it's redundant against itself if i == i2 { continue ; } // This is 'true' if `link` and `link2` are equal apart from their course head masks. // We don't check the names, since it's possible that the same link is given two // different names (e.g. near near would generate `pI` and `pT` which should be // considered identical).  If the links do have different names, then one of them is // picked arbitrarily. let are_links_otherwise_equal = link . eq_without_name_or_ch_mask ( link2 ) ; if are_links_otherwise_equal { if link . ch_mask == link2 . ch_mask { // If the links are identical, then we remove the one with the least index. // This way, exactly one link from a group of identical links (the one with the // highest index) will survive if i < i2 { redundant_link_idxs . push ( i ) ; } } else if link . ch_mask . is_subset_of ( & link2 . ch_mask ) { // If `link2`'s CH mask is more general than `link`'s, and `link` and `link2` // are otherwise equal, then `link` is a special case of `link2` and is // therefore redundant redundant_link_idxs . push ( i ) ; } } } } // Now actually remove the unnecessary links, making sure to iterate backwards so that the // indices keep pointing to the right elements redundant_link_idxs . sort_unstable ( ) ; redundant_link_idxs . dedup ( ) ; for idx in redundant_link_idxs . into_iter ( ) . rev ( ) { links . remove ( idx ) ; } }
Remove any [`Link`]s which are equal to another [`Link`] (ignoring names).
Remove any [ ` Link ` ] s which are equal to another [ ` Link ` ] ( ignoring names ) .
links
&mut Vec<Link>
links
&mut Vec<Link>