Why is functional Currying right associative in rust?

⚓ rust    📅 2025-05-22    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 38 days ago. The information described in this article may have changed.

As you can see, the right expression is returned and used as the input for the left closure. This process is called querying. Why is it right-associative in Rust?

fn calculate_translation(border: f32, current_number: f32) -> f32 {
    (|half_border| {
        current_number
            + rand::rng().random_range(match current_number {
                n if n >= half_border => -40.0..0.0,
                n if n <= -half_border => 0.0..40.0,
                _ => -40.0..40.0,
            })
    })(border / 2.0)
}

10 posts - 8 participants

Read full topic

🏷️ rust_feed