Rewrite it in Rust