apply_str_str

Function apply_str_str 

Source
pub fn apply_str_str<T, U>(
    lhs: StringAVT<'_, T>,
    rhs: StringAVT<'_, U>,
    op: ArithmeticOperator,
) -> Result<StringArray<T>, KernelError>
where T: Integer, U: Integer,
Expand description

Applies an element-wise binary operation between two StringArrays, producing a new StringArray. Requires both arrays to have the same length.

Supported operations:

  • Add: Concatenates each pair of strings (a + b).
  • Subtract: Removes the first occurrence of b from a, if present. If b is empty or not found, a is returned unchanged.
  • Multiply: Repeats string a N times, where N = min(b.len(), STRING_MULTIPLICATION_LIMIT).
  • Divide: Splits string a by occurrences of b and rejoins the segments using a '|' separator. If b is empty, returns a unchanged.

Null handling:

  • If either side is null at an index, the output will be null at that index.

Returns:

  • A new StringArray<T> containing the result of applying the binary operation to each pair.

Errors:

  • Returns KernelError::LengthMismatch if lhs and rhs lengths differ.
  • Returns KernelError::UnsupportedType if an unsupported binary operator is passed.

ยงFeatures

This function is available only when the str_arithmetic feature is enabled.