Using AI to generate Rust code

⚓ rust    📅 2025-04-24    👤 surdeus    👁️ 2      

surdeus

Hello,

I'm looking for advice and to hear about experiences about generating Rust code using AI.

I'm part of a team that has become very enthusiastic about generating code using AI. We are a research group that includes computational researchers and software engineers. Projects range from smaller pieces of Python or R code to implement novel analysis methods for research to larger pieces of infrastructure in Java, Scala or (if I'm responsible for the choice) Rust, or JavaScript, mostly Vue, for the WebUI.

Last week, ChatGPT published o3, and our PI (i.e. principal investigator, i.e. our boss), entirely by prompting o3, was able to take a Python function that implemented a complex mathematical algorithm we invented, turn it into a description of the algorithm, turn that into a more advanced version of the algorithm, and turn it back into a Python function.

So now, obviously, he believes we should generate most (if not all) of our code using AI, instead of writing it ourselves.

So I'm wondering how successful people have been in generating Rust code by AI?

My guess would be that it is not feasible to generate a project that includes dozens of functions or types with a single prompt. Or is it?

So the main problem seems to be how to use AI to modify an existing project. What are the possible ways to do that?

I've been using JetBrain's RustRover with the GitHub Copilot plugin since a few months, mostly for its autocomplete suggestions, which range from rest of the line to entire functions. It's been useful, but mixed. Sometimes it suggests exactly what I want. Sometimes it suggests code that works, but is sub-optimal. Sometimes it suggests code that looks right at first glance but turns out to be incorrect. Sometimes the suggestions are silly, like suggesting a function that already exists. Surprisingly often, the suggested code actually compiles, and if it doesn't, it is often because it suggested using a function that doesn't exist but could be plausibly expected to exist.

GitHub Copilot also allows prompting, but I haven't used that much, mostly because I'm not sure how that would integrate with the rest of the code.

RustRover now also comes with its own AI. This one allows prompting for adding code at a specific location. I have not yet have much chance to try it out. My very very little experience with it makes me feel it is comparable to GitHub Copilot, but I need to use it more to tell.

So what do other people do? Thanks!

4 posts - 4 participants

Read full topic

🏷️ rust_feed