Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

reversing_partial_result

Reverses elements from a word onto an existing partial result

This function extends the reversing operation by allowing it to build upon an existing partial result. It extracts elements from the input word and appends them to the ongoing result, useful for multi-stage reversing operations.

The step parameter MUST be a power of 2 (e.g., 2, 256, 65536). Using a non-power-of-2 step will produce incorrect results and data corruption. Valid steps: 2 (bits), 256 (bytes), 65536 (u16 words), etc.

Arguments

  • word - The value to extract elements from for reversal
  • onto - The existing partial result to build upon
  • size - The number of elements to reverse and append
  • step - The step size for each element (MUST be a power of 2: 2, 256, 65536, etc.)

Returns

  • (T, T) - A tuple containing (final_result_with_appended_elements, remaining_word)

Panics

  • If step is not a power of 2 (runtime check performed)

Fully qualified path: alexandria_bytes::reversible::reversing_partial_result

pub fn reversing_partial_result<
    T,
    +Copy<T>,
    +DivRem<T>,
    +TryInto<T, NonZero<T>>,
    +Into<T, u128>,
    +TryInto<u128, T>,
    +Drop<T>,
    +MulAssign<T, T>,
    +Rem<T>,
    +AddAssign<T, T>,
>(
    mut word: T, mut onto: T, size: u32, step: T,
) -> (T, T)