# Idiomatic Rust Code and LLMs

> Source: <https://www.dotnetperls.com/2026_10_9_idiomatic-rust-code-llms>
> Published: 2026-10-09 07:00:00+00:00

I used **Step 5 Preview** today (from StepFun) to generate some **Rust code**. It worked correctly, but like the code I generated with Mistral Large 4, it was not really **idiomatic Rust code**. Instead it uses a lot of `idx` local variables and byte accesses like you would see in C code.

Meanwhile, **Claude** (From Opus to Haiku) and GPT seem to have become **proficient** at writing idiomatic Rust code. This means using standard library functions (like `position` and `is_ascii_whitespace`), `Option`, `iter`, `map`.

For example, in Rust it is **much cleaner** to use `is_ascii_whitespace` to test for a whitespace byte, and use `position` instead of a loop. Even though code from models that do not write idiomatic Rust code as eagerly works, I tend to end up **preferring** Claude or GPT. Even **Claude Haiku 5.5**, which is really cheap, can do this, but large, expensive competing models cannot. I recommend a **change** in **training data** for some of the AI companies.
