How do i see the `Cargo.toml` when I run my code in Rust Playground?

How do i see the Cargo.toml when I run my code in Rust Playground?
I need this to check crate's version on which playground is running my code on. Also, is it possible to modify this Cargo.toml?

Rust Playground doesn't support this. You can use Rust Explorer instead.

2 Likes

Here's one way.

fn main() {
    let cargo = std::fs::read("Cargo.lock").unwrap();
    print!("{}", String::from_utf8(cargo).unwrap());
}

No, the playground is locked down to prevent resource exploitation and other abuse.

There's more flexible playgrounds but I'm personally unaware of how flexible the versions available are.

4 Likes

this playground prints the crate's version. See: Environment Variables - The Cargo Book