Skip to main content

Module expr

Module expr 

Source
Expand description

Expression-to-Rust translation helpers.

Converts Python AST expression nodes into Rust source strings. All functions are pure (no I/O, no state).

Functions§

constant_to_rust
Convert a Python constant value to its Rust literal equivalent.
expr_to_rust
Translate a Python expression to a Rust expression string.
translate_for_iter
Translate a Python for-loop iterator expression to a Rust range string. Handles: range(n)0..n, range(a, b)a..b, fallback to expr_to_rust.
translate_len_guard
Translate a Python if-test that guards a length check into a Rust guard string. Returns None if the test is not a simple equality/inequality comparison.
translate_while_test
Translate a Python while-loop test expression to Rust.