Implementing algorithms in Rust