Managing a software project with Cargo
Before we start structuring our program with Cargo, we should build a basic single-file application. To do this, we initially must create a file called hello_world.rs
in a local directory. The .rs
extension denotes that the file is a Rust file. To be honest, it does not matter what the extension is. If there is viable Rust code written in that file, the compiler will compile and run it without any issues. However, having different extensions might confuse other developers and code editors and cause problems when importing code from other Rust files. So, it is best to use .rs
when naming your Rust files. Inside our hello_world.rs
file, we can have the following code:
fn main() { println!("hello world"); }
This is no different from our first code block in the previous chapter. Now that we have defined our entry point in our hello_world.rs
file, we can compile the file with the following command:
rustc hello_world...