Running rust code

So at first i write a rust code and then saved it with a .rs extension afterwards when i try to run it i have no options to be seen for running in vs code . i have to manually compile and exe the file through terminal whereas if i use " cargo new filename " and open that folder in vscode it is fine like shows run option as well as debug option . I can't understand why these occurred .

The vscode extension for Rust relies on the Cargo.toml file to recognize a "project"
It doesn't work well with editing rust files that don't belong to a project.

cargo: tool for managing rust projects (dependencies, build steps etc)
rustc: rust compiler that converts rust to executables (used by cargo)
rust-script (installed with cargo install rust-script) tool to execute a single rust file from the command line in one step (e.g. rust-script


Oh now I see how it works , it is quite different from python. Maybe that is why I faced such an issue .