rust-lang / rust-playground

The Rust Playground
https://play.rust-lang.org/
Apache License 2.0
1.26k stars 206 forks source link

Allow shared code examples to include `Cargo.toml` for educational purposes. #810

Open daveloyall opened 2 years ago

daveloyall commented 2 years ago

Hello.

Various folks use play.rust-lang.org to share code for educational purposes. Sometimes it would be useful for that code to include a Cargo.toml.

This especially includes all the examples that "just work" because of the "top 100 crates" that are included in the implicit Cargo.toml already...

shepmaster commented 2 years ago

I encourage you to use the crate autocomplete for that, as it includes the crate version:

2022-06-08 22 30 56

otherwise, you can link to the current Cargo.toml. This is linked from the help page.

Can you be more specific about exactly what change you want to see?

daveloyall commented 2 years ago

So far, I've only viewed code that others shared via the Playground. I haven't shared any of my own.

Now that I know a lot more about how the Playground works, I think I won't have the same kind of trouble anymore.

Maybe change how the link to Cargo.toml on the help page is described. The first time I used the Playground, I probably just clicked ❓ and then C-f cargo to search the page. That method does not highlight the link.

I read somewhere (probably in docs I found on rust-lang.org) that snippets of Rust are meaningless without a Cargo.toml. ..I'm sure I'm paraphrasing. Maybe that is why I found the Playground confusing before I knew (a bit about) how it works.