I am aware of Rust cargo clippy and perhaps this is the best option, I dont know.
I am new to Rust.
I use VS Code and Rust-Analyzer which seem to work well enough.
When I write a fragment of the Rust code I wonder if there is a tool that may offer me a suggestion on re-writing the Rust code (fragment) to be either/or more idiomatic or more performant etc?
I believe some IntelliJ IDE offer such tooling and perhaps Visual Studio does for C# and C++.
So I am wondering if Rust has something along these lines too?
I tried using cargo clippy (clippy::style?) but its seems to be more towards lints rather than code fragment re-factoring.
I wanted to use this tool (if it exists) to help me improve the way I write Rust.
Is there anything you can recommend?
Is Rust cargo clippy my best option ?
Maybe you could provide more details on what differentiates the thing you’re looking for from a linter?
You’re referencing existing tooling for C# and C++; maybe you could provide an example for the types of suggestions in C#/C++ that you consider “fragment re-factoring”.
thank you for your reply.
Here is a pseudo example: say I write a conventional loop processing lines of a file, like I would in C. I would like such a tool to suggest using an iterator fluent approach using constructs like file_iter.lines().filter().map() etc. Or in case of dealing with Options and Results to suggest using ? operator or using if let or while let. Of if I write a deeply nested if/else then it may re-write it using a match statement.
I guess I am looking at a tool that would act like a very experienced Rust developer would when looking at the "junior" code and suggesting better ways to write the same thing.
I see clippy offering many very good suggestions already but from what I see those are on narrower level.
I hope it makes sense.
Yeah, I wouldn't know anything besides clippy either. Automatic tools can only be so smart, maybe the degree of help that you wish for isn't really technically possible. (yet.)
(If there's any concrete lints/help things that tooling of other language provides that you're missing in clippy or rust-analyzer, maybe open an issue.)
If you're ever thinking that a particular piece of code of yours feels like there ought to be a better way to write it but you don't know how, or you aren't sure which choice between a few options is the most idiomatic, you're always welcome to ask for help or code review in this forum
yes, thank you,
this forum has been most helpful to me, I think Rust has such a great community!!
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.