depyler-core 3.22.0

Core transpilation engine for the Depyler Python-to-Rust transpiler
Documentation
// Generated by: DEPYLER stdlib validation Phase 1
// Module: functools/itertools - Functional programming basics for 50% milestone
// Status: GREEN phase - Tests enabled, all already implemented

use depyler_core::transpile_python_to_rust;

// Note: ALL 3 functional programming functions were already implemented!

// DEPYLER-STDLIB-FUNCTOOLS-001: Reduce function
#[test]
fn test_functools_reduce() {
    let python = r#"
from functools import reduce

def sum_reduce(items: list) -> int:
    return reduce(lambda x, y: x + y, items)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    // Should reduce list with accumulator function
    assert!(result.contains("fold") || result.contains("reduce"));
}

// DEPYLER-STDLIB-ITERTOOLS-001: Chain iterators
#[test]
fn test_itertools_chain() {
    let python = r#"
from itertools import chain

def chain_lists(a: list, b: list) -> list:
    return list(chain(a, b))
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    // Should chain multiple iterators
    assert!(result.contains("chain") || result.contains("extend"));
}

// DEPYLER-STDLIB-ITERTOOLS-002: Cycle through iterator
#[test]
fn test_itertools_cycle() {
    let python = r#"
from itertools import cycle

def cycle_items(items: list, n: int) -> list:
    cycler = cycle(items)
    return [next(cycler) for _ in range(n)]
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    // Should cycle through items infinitely
    assert!(result.contains("cycle") || result.contains("iter"));
}

// Total: 0 NEW functional programming utilities (all 3 already existed!)
// Coverage: functools.reduce(), itertools.chain(), itertools.cycle()