Skip to main content

duplicate_keyed_loop_message

Function duplicate_keyed_loop_message 

Source
pub fn duplicate_keyed_loop_message(
    loop_desc: &str,
    key: &str,
    first_position: usize,
    second_position: usize,
) -> String
Expand description

The message a keyed by loop whose siblings share a key fails with — the SAME wording on every tier, because the lowering of Each builds it at run time from the segments this function formats (duplicate_keyed_loop_message_parts). loop_desc names what is being iterated (expr_shape on the loop’s own iterable, e.g. "todos"); key is the colliding key’s own display value (its evaluated VALUE, not source text — two items collide on what a key IS, at runtime, never on how it was spelled).

first_position/second_position are 1-BASED — every position an author sees is (Tristen’s decision), matching at index, which already counts from LOOP_INDEX_BASE, never from 0. Each.index being 0-based is this crate’s own implementation detail; a caller converts before calling (i + 1), so a raw internal index can never reach this message un-shifted.