depyler-core 3.22.0

Core transpilation engine for the Depyler Python-to-Rust transpiler
Documentation
// Generated by: DEPYLER stdlib validation Phase 1
// Module: str - Additional string methods
// Status: GREEN phase - Tests enabled

use depyler_core::transpile_python_to_rust;

// Note: count() and find() were already implemented
// This commit adds 3 NEW methods: index, rfind, rindex

// DEPYLER-STDLIB-STR-ADDITIONAL-001: Index with error on not found
#[test]
fn test_str_index() {
    let python = r#"
def get_index(text: str, sub: str) -> int:
    return text.index(sub)
"#;

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

    // Should find index or panic
    assert!(result.contains("find") && result.contains("expect"));
}

// DEPYLER-STDLIB-STR-ADDITIONAL-002: Reverse find
#[test]
fn test_str_rfind() {
    let python = r#"
def find_last(text: str, sub: str) -> int:
    return text.rfind(sub)
"#;

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

    // Should find last occurrence
    assert!(result.contains("rfind"));
}

// DEPYLER-STDLIB-STR-ADDITIONAL-003: Reverse index
#[test]
fn test_str_rindex() {
    let python = r#"
def get_last_index(text: str, sub: str) -> int:
    return text.rindex(sub)
"#;

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

    // Should find last index or panic
    assert!(result.contains("rfind") && result.contains("expect"));
}

// Total: 3 NEW str methods (count, find already existed)
// Coverage: index(), rfind(), rindex()