Skip to main content

confirm_equal_len

Function confirm_equal_len 

Source
pub fn confirm_equal_len(
    label: &str,
    a: usize,
    b: usize,
) -> Result<(), KernelError>
Expand description

Validates that two lengths are equal for binary kernel operations.

Critical validation function ensuring input arrays have matching lengths before performing binary operations like comparisons, arithmetic, or logical operations. Prevents undefined behaviour and provides clear error diagnostics when length mismatches occur.

§Parameters

  • label: Descriptive context label for error reporting (e.g., “compare numeric”)
  • a: Length of the first input array or data structure
  • b: Length of the second input array or data structure

§Returns

Ok(()) if lengths are equal, otherwise KernelError::LengthMismatch with diagnostic details.