Consider this Rust program managed by Cargo. What will it print when run?
fn main() {
println!("Hello from Cargo!");
}Think about what println! does and how Cargo runs Rust programs.
The program prints exactly the string inside println!. Cargo compiles and runs the code, so the output is Hello from Cargo!.
Rust developers often switch between Rust versions. Which tool helps manage and switch Rust versions easily?
Think about the tool that installs Rust and manages multiple versions.
rustup is the Rust toolchain installer and version manager. It lets you install and switch between Rust versions easily.
Look at this Rust code snippet. What error will rustc show?
fn main() {
let x: i32 = "hello";
println!("{}", x);
}Check the type assigned to x and the value given.
The variable x is declared as an integer but assigned a string literal. Rust's compiler rustc reports a type mismatch error.
Choose the correct Cargo command to build a Rust project optimized for release.
Think about the command that compiles the code with optimizations.
cargo build --release compiles the project with optimizations for release. Other commands serve different purposes.
You run rustup override set nightly inside a Rust project folder. What is the effect?
Consider how rustup override affects Rust versions locally vs globally.
rustup override set nightly sets the Rust version to nightly only for the current folder, overriding any global or default version.