Skip to main content

validate_case_classes

Function validate_case_classes 

Source
pub fn validate_case_classes(
    set1_classes: &[CaseClassInfo],
    set2_classes: &[CaseClassInfo],
) -> Result<(), String>
Expand description

Validate that [:upper:] and [:lower:] classes are properly paired between SET1 and SET2.

GNU tr rules:

  • Every case class in SET2 MUST have a matching case class (same or opposite) at the same expanded position in SET1. If not, error.
  • Case classes in SET1 that don’t have a corresponding class in SET2 are fine — they’re just treated as expanded character sets (26 chars) with normal SET2 extension.

This means:

  • tr '[:lower:]' 'xyz' is fine (SET1 has class, SET2 doesn’t → normal mapping)
  • tr 'abc' '[:upper:]' is an error (SET2 has class, SET1 doesn’t)
  • tr '[:lower:][:upper:]' '[:upper:]xyz' is fine (SET1 upper at pos 26 maps to xyz)
  • tr 'A-Z[:lower:]' 'a-y[:upper:]' is an error (SET2 upper at pos 25, SET1 lower at pos 26)