Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I asked ChatGPT for a Rust port, https://play.rust-lang.org/?version=stable&mode=debug&editio...

I had to make zero changes, it appears to work.



Although input.chars().nth() is not good - because of how strings work in Rust, that has to iterate over the string, rather than indexing directly, so O(n) rather than O(1). I think the idiomatic efficient translation would be to use a CharIndices iterator to track each end of the window.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: