General Rust VII
1.
What is the purpose of the `const` keyword in Rust?
To declare a constant
To define a generic type
To represent a numeric type
To perform arithmetic operations
2.
How does Rust handle dynamic dispatch for trait objects without using `dyn`?
By using the `trait` keyword
By relying on garbage collection
By implicitly enabling dynamic dispatch
By enforcing static dispatch
3.
What is the purpose of the `std::mem::forget` function in Rust?
To explicitly leak memory without running destructors
To free memory allocated with `malloc`
To perform arithmetic operations
To declare a constant
4.
What is the purpose of the `assert_eq!` macro in Rust tests?
To check that two values are equal
To define a new module
To create a constant
To handle exceptions
5.
How does Rust handle string concatenation efficiently?
By using the `String::push_str` method
By relying on garbage collection
Through automatic reference counting
By using the `+` operator with ownership transfer
6.
How does Rust handle function parameters with default values?
By using function overloading
By relying on garbage collection
By using the `default` keyword
Rust does not support function parameters with default values
7.
What is the purpose of the `std::ops::Deref` trait in Rust?
To overload the dereference operator (`*`)
To create a new module
To handle exceptions
To represent a numeric type
8.
How does Rust enforce immutability and mutability through borrowing?
By using explicit references and borrowing rules
By relying on garbage collection
By enforcing runtime checks
By using the `immutable` and `mutable` keywords
9.
How does Rust ensure thread safety with the `Mutex` type?
By providing exclusive access with locks
By using automatic reference counting
By relying on garbage collection
By enforcing runtime checks
10.
How does Rust handle exceptions in the absence of `Result` or `Option`?
By panicking and unwinding the stack
By returning a default value
By relying on garbage collection
By printing an error message
11.
What does the `std::fs::remove_file` function do in Rust?
Removes a file from the filesystem
Creates a new file
Opens an existing file
Retrieves file metadata
12.
How does Rust represent a two-dimensional array?
Using an array of arrays
Using a tuple of vectors
Using a vector of vectors
By relying on garbage collection
13.
How does Rust implement trait inheritance?
Through trait bounds and composition
By relying on garbage collection
By using the `extends` keyword
By enforcing strict inheritance rules
14.
What is the role of the `std::sync::RwLock` type in Rust?
To provide read-write access with synchronized locks
To represent a numeric type
To create a new module
To enforce strict ownership rules
15.
What is the purpose of the `dbg!` macro in Rust?
To print the value of an expression for debugging
To define a new module
To create a constant
To handle exceptions
16.
What is the purpose of the `std::thread::sleep` function in Rust?
To pause the execution of the current thread
To define a new thread
To handle exceptions
To create a constant
17.
How does Rust implement pattern matching for enums?
Using the `match` keyword
By relying on garbage collection
Through automatic reference counting
By using the `enum` keyword
18.
What is the purpose of the `std::time::Instant` type in Rust?
To represent a date and time
To define a macro
To handle exceptions
To measure elapsed time
19.
What is the purpose of the `#[derive(Serialize, Deserialize)]` attribute in Rust?
To automatically implement serialization and deserialization traits
To declare a constant
To create a new module
To handle exceptions
20.
How does Rust handle function parameters with variable numbers?
Using the `std::env::args` function
By relying on garbage collection
By using the `...` syntax
By using variadic arguments