Explanation: 'cargo' is Rust's package manager and build system.
Dear candidates you will find MCQ questions of Rust here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question
Explanation: 'cargo' is Rust's package manager and build system.
Explanation: Rust uses the macro 'println!' to print to the console.
fn main() {
let s = String::from("hello");
let t = s;
println!("{}", s);
}
Explanation: Ownership of 's' is moved to 't', so 's' is no longer valid.
Explanation: Rust uses 'return' to return values from functions.
Explanation: 'Result' is used for error handling and represents success or failure.
Explanation: Rust uses the 'struct' keyword to define custom data types.
fn main() {
let x = vec![1, 2, 3];
println!("{}", x[1]);
}
Explanation: Indexing starts at 0, so x[1] is 2.
Explanation: Rust uses 'impl' to implement traits for types.
Explanation: 'unwrap()' returns the value if Ok, or panics if Err.
Explanation: Macros in Rust are marked with a '!' like 'println!'.