Convert to Rust some code