Home > Internet Programming > Quizzes > Rust (Programming Language) Quiz
Rust (Programming Language) Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 29% Most missed: “How do you create a Rust project on the command-line?”

Rust (Programming Language) MCQs For LinkedIn Skill Assessments.

Rust (Programming Language) Quiz
Time left 00:00
25 Questions

1. In matching patterns, values are ignored with \_.
2. Generics are useful when you '\_'.
3. Which type cast preserves the mathematical value in all cases?
4. Which choice is _not_ valid loop syntax?
5. How do you construct a value of 'Status' that is initialized to 'Waiting'?
rust
enum Status {
Waiting,
Busy,
Error(String),
}
6. Which 'cargo' command checks a program for error without creating a binary executable?
7. Which idiom can be used to concatenate the strings 'a', 'b', 'c'?
rust
let a = 'a'.to_string();
let b = 'b'.to_string();
let c = 'c'.to_string();
8. What happens when an error occurs that is being handled by the question mark (?) operator?
9. In this function. what level of access is provided to the variable 'a'?
rust
use std::fmt::Debug;
fn report(a: &T) {
eprintln!('info: {:?}', a);
}
10. How do you create a Rust project on the command-line?
11. What is a safe operation on a 'std::cell:UnsafeCell'?
12. Which statement about the 'Clone' and 'Copy' traits is false?
13. Does the 'main' function compile? If so, why? If not, what do you need to change?
rust
fn main() {
let Some(x) = some_option_value;
}
14. Which is valid syntax for defining an array of i32 values?
15. What is an alternative way of writing 'slice' that produces the same result?
rust
...
let s = String::form('hello');
let slice = &s[0..2];
16. Which fragment does not incur memory allocations while writing to a 'file' (represented by a Vec)?
rust
use std::collections::HashMap;
fn main() -> Result<(), Box> {
let mut v = Vec::::new();
let a = 'LinkedIn';
let b = 123;
let c = '
17. The term _box_ and related phrases such as _boxing a value_ are often used when relating to memory layout. What does _box_ refer to?
18. Which example correctly uses std::collections::HashMap's Entry API to populate counts?
rust
use std::collections::HashMap;
fn main() {
let mut counts = HashMap::new();
let text = 'LinkedIn Learning';
for c in text.chars() {
// Complete this block
}
println!('{:?}', counts);
}
19. What syntax is required to take a mutable reference to T, when used within a function argument?
rust
fn increment(i: T) {
// body elided
}
20. Why does this code _not_ compile?
rust
fn returns_closure() -> dyn Fn(i32) -> i32 {
|x| x + 1
}
21. What does an underscore (\_) indicate when used as pattern?
22. '\_' cannot be destructured.
23. Your application requires a single copy of some data type T to be held in memory that can be accessed by multiple threads. What is the thread-safe wrapper type?
24. Which comment syntax is not legal?
25. When used as a return type, which Rust type plays a similar role to Python's 'None', JavaScript's 'null', or the 'void' type in C/C++?