I just set up Rust according to the doc and created my first program.
fn main() {
println!("Hello, world!");
}
I saved it as main.rs
and kicked off using:
[root@localhost hello_world] rustc main.rs
[root@localhost hello_world]
But no output ever appears. Running rustc --version
does show the version number, so considering the install went without problem, I am wondering where the problem is.
Rust is a compiled language. rustc
is the compiler, which takes a source file and produces a binary which can then be executed; it does not itself execute the code, however. You must take the binary it produces (by default, the source filename minus the .rs
extension) and execute it yourself with ./main
or similar.
If you use Cargo, there is cargo run
which compiles the code if necessary and then runs it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With