General Rust IX
1.
What is the purpose of the `std::marker::PhantomData` type in Rust?
To represent a numeric type
To enforce variance in type parameters
To handle file I/O operations
To indicate ownership in structs with lifetimes
2.
What is the purpose of the `std::ops::Add` trait in Rust?
To overload the addition operator (`+`)
To declare a constant
To represent a numeric type
To handle exceptions
3.
How does Rust handle function parameters with default values?
By using the `= default` syntax
By relying on garbage collection
By using the `default` keyword
Rust does not support function parameters with default values
4.
How does Rust enforce the `Sync` trait for types?
By ensuring that a type can be safely transferred between threads
By using global locks and mutexes
By relying on garbage collection
By enforcing strict ownership rules
5.
What is the purpose of the `std::ops::BitXor` trait in Rust?
To represent a numeric type
To overload the bitwise XOR operator (`^`)
To declare a constant
To handle exceptions
6.
How does Rust handle type annotations for function return values?
By using the `->` syntax
By relying on garbage collection
By inferring types based on the function body
By using the `type` keyword
7.
How does Rust implement dynamic dispatch for trait objects with associated types?
By using the `dyn` keyword
By relying on garbage collection
By automatically inferring associated types
By explicitly specifying associated types
8.
What is the purpose of the `std::ops::Neg` trait in Rust?
To declare a constant
To represent a numeric type
To handle exceptions
To overload the unary negation operator (`-`)
9.
How does Rust represent a function that takes no arguments and returns a boolean?
Using the `Fn` trait
Using the `() -> bool` signature
By relying on garbage collection
Using the `bool` keyword
10.
How does Rust handle memory layout for enums with associated data?
By ensuring the largest variant determines the overall size
By using a fixed size for all variants
By relying on garbage collection
By enforcing strict ordering of variants
11.
How does Rust handle ownership in the context of closures?
By inferring ownership based on the closure's environment
By using the `move` keyword to transfer ownership
By relying on garbage collection
By enforcing runtime checks
12.
How does Rust handle generic programming with trait bounds?
By specifying trait bounds in function and struct definitions
By relying on garbage collection
Through automatic lifetime inference
By using the `generic` keyword
13.
How does Rust manage lifetimes for function parameters when omitted?
By using lifetime elision rules
By relying on garbage collection
By enforcing strict lifetime annotations
By inferring lifetimes based on the function body
14.
What does the `std::ptr::eq` function do in Rust?
Compares raw pointers for equality
Compares the values pointed to by raw pointers
Creates a new raw pointer
Converts a raw pointer to a reference
15.
What is the purpose of the `std::collections::HashSet` type in Rust?
To represent a numeric type
To store unique values without duplicates
To create a new module
To handle file I/O operations
16.
What is the purpose of the `std::io::Error` type in Rust?
To represent a numeric type
To handle file I/O errors
To declare a constant
To define a generic type
17.
What is the purpose of the `std::num::ParseIntError` type in Rust?
To handle file I/O errors
To represent a numeric type
To declare a constant
To represent errors during integer parsing
18.
What is the purpose of the `std::sync::Condvar` type in Rust?
To handle file I/O operations
To represent a numeric type
To synchronize threads based on a condition
To declare a constant
19.
What is the purpose of the `std::cell::Cell` type in Rust?
To represent a numeric type
To provide interior mutability without borrowing
To create a new module
To handle file I/O operations
20.
How does Rust handle lifetimes in function parameters by default?
Through lifetime elision rules
By relying on garbage collection
By enforcing strict lifetime annotations
By inferring lifetimes based on the function body