TL;DR for the below: adding dependencies could perhaps be improved, and using explicit versions instead of
= "*" has some benefits. And there's certain convenience features the
playground has that I might be missing. By the way I haven't really used
rustexplorer.com all that much yet.
When working on my local machine, for "playground"-style projects I always use
cargo add and
cargo feature subcommands to modify dependencies. If there was any way to get the same kind of experience through this website, that would be impressive. IDK, maybe even by running the actual
cargo add command, and writing modifications back into the dependencies doc-comment (or creating one if non-existent). (I have no idea how easy/feasable/useful this would actually be though.)
Some "more integrated" kind of indication as to what crates are and aren't supported seems potentially nice, too. Maybe if there was some UI for running
cargo add, then typing the command name could offer completions (from the list of available crates) after a few letters are typed?
For the normal playground, you just need to type (part of)
use crate_name, and it completes it for you (while indicating the crate version used); the list of supported crates isn't too large, but finding and using them is really easy.
In a perfect world, you could offer completions is a similar style, and make it automatically (create or) update the
dependencies section accordingly, in case the completion is used/accepted by the user. The automatically added dependency would also clearly indicate (and thus document) the latest available version that's used, so that any older shared rustexplorer links would not break due to breaking changes in the dependencies, something that can happen if version
= "*" is used instead. (They might still stop running successfully, in case old versions of a crate become unavailable in rustexplorer in the future, but the source code would contain all the version information necessary to get the code running locally.)
Also, if a compilation error includes messages like
^ no external crate `foo` or
^ use of undeclared crate or module `foo` , you might be able to detect this, look up the crate name in your list of supported crates, and suggest the user that they could confirm adding it to
[dependencies]. Speaking of error messages, the playground has some conveniently clickable
consider importing one of these items instead error messages, where you can click on the suggested
use statements to have them added to your code. Admitted that feature is a bit broken/unpolished on the playground, because it will always add it at the beginning of the file, even before potentially existing
#! attributes (resulting in broken code), but I tend to use it regularly nonetheless. Also the playground's support for other modes of execution besides running the code, and automatic detection of whether a
main function is present, is quite convenient.
I guess most of these are nontrivial and low priority features, feel free to ignore or postpone most of this.