Port code to support the latest Rust