/// Generate an error if any course could be given two course heads at **different** lead
/// locations.
///
/// For example, in a method with Plain Bob lead heads, `1xx3xx78` and `1x56x8x7` would create an
/// ambiguity because some courses could either be labelled `15x3x678` or `1356x8x7`.
Generate an error if any course could be given two course heads at **different** lead
locations.


Generate an error if any course could be given two course heads at ** different ** lead locations .
pub(super) fn check_for_ambiguous_courses(
    course_head_masks: &[CourseHeadMask],
    lead_heads: &[RowBuf],
) -> Result<()> {
    for (i, ch_mask) in course_head_masks.iter().enumerate() {
        let mask = &ch_mask.mask;
        for lead_head in lead_heads.iter() {
            if lead_head.is_rounds() {
                continue; // It's OK for two CH masks to label the same lead as a course head
            }
            // ... compute mask for this lead head at this location ...
            let transposed_mask = mask.mul(lead_head);
            // ... and check that it isn't compatible with any of the course head mask we've
            // seen so far.  We only need to check each pair of CH masks once (since ambiguity
            // is symmetric).
            for other_ch_mask in &course_head_masks[..=i] {
                let other_mask = &other_ch_mask.mask;
                // If the lead-end is compatible with a course head mask, then derive which
                // leads are ambiguous, and return an error
                if let Some(course_head_2) = transposed_mask.combine(other_mask) {
                    // Generate the second course head by transposing `mask2` at this lead
                    // back to the course head satisfying `mask`
                    let course_head_1 = other_mask.mul(&lead_head.inv()).combine(mask).unwrap();
                    return Err(Error::AmbiguousCourseHeadPosition {
                        mask1: course_head_1,
                        input_mask1: mask.clone(),
                        mask2: course_head_2,
                        input_mask2: other_mask.clone(),
                    });
                }
            }
        }
    }
    Ok(())
}
pub ( super ) fn check_for_ambiguous_courses ( course_head_masks : & [ CourseHeadMask ] , lead_heads : & [ RowBuf ] , ) -> Result < ( ) > { for ( i , ch_mask ) in course_head_masks . iter ( ) . enumerate ( ) { let mask = & ch_mask . mask ; for lead_head in lead_heads . iter ( ) { if lead_head . is_rounds ( ) { continue ; // It's OK for two CH masks to label the same lead as a course head } // ... compute mask for this lead head at this location ... let transposed_mask = mask . mul ( lead_head ) ; // ... and check that it isn't compatible with any of the course head mask we've // seen so far.  We only need to check each pair of CH masks once (since ambiguity // is symmetric). for other_ch_mask in & course_head_masks [ .. = i ] { let other_mask = & other_ch_mask . mask ; // If the lead-end is compatible with a course head mask, then derive which // leads are ambiguous, and return an error if let Some ( course_head_2 ) = transposed_mask . combine ( other_mask ) { // Generate the second course head by transposing `mask2` at this lead // back to the course head satisfying `mask` let course_head_1 = other_mask . mul ( & lead_head . inv ( ) ) . combine ( mask ) . unwrap ( ) ; return Err ( Error :: AmbiguousCourseHeadPosition { mask1 : course_head_1 , input_mask1 : mask . clone ( ) , mask2 : course_head_2 , input_mask2 : other_mask . clone ( ) , } ) ; } } } } Ok ( ( ) ) }
Generate an error if any course could be given two course heads at **different** lead
locations.
Generate an error if any course could be given two course heads at ** different ** lead locations .
course_head_masks
&[CourseHeadMask]
lead_heads
&[RowBuf]