General Rust III
1.
What does the `#[derive(Debug)]` attribute do in Rust?
Declares a new module
Automatically implements the `Debug` trait for a type
Indicates a macro
Specifies the visibility of a variable
2.
What is the purpose of the `Rc` type in Rust?
To represent a tuple
To create reference-counted smart pointers
To handle ownership of a value
To efficiently handle borrowed data
3.
How does Rust handle panics in the standard library?
By abruptly terminating the program
By ignoring panics
By unwinding the stack
By printing an error message
4.
How does Rust handle asynchronous programming?
By relying on automatic parallelization
By using global variables
Through manual thread management
Through the `async/await` syntax
5.
What is the purpose of the `Copy` trait in Rust?
To create deep copies of values
To define a macro
To represent a numeric type
To implement garbage collection
6.
What does the `std::mem::size_of` function return in Rust?
The maximum value of a type
The size of a type in bytes
The memory address of a variable
The number of elements in an array
7.
How does Rust manage dependencies in a project?
By manually downloading and including library files
Using the `Cargo.toml` file and the `Cargo` package manager
Through a global dependency registry
By relying on automatic dependency resolution
8.
What is the purpose of the `Arc` type in Rust?
To manage the lifetime of a variable
To represent an array
To handle ownership of a value
To create atomic reference-counted smart pointers
9.
How does Rust handle unwinding in the presence of panics?
Through stack unwinding
By abruptly terminating the program
By relying on garbage collection
By using the `panic_handler` function
10.
How does Rust ensure memory safety without a garbage collector?
Through ownership and borrowing rules
By using automatic reference counting
By relying on runtime checks
By enforcing strict typing
11.
What is the purpose of the `Into` trait in Rust?
To declare a function
To convert a value into another type
To define a generic type
To handle exceptions
12.
How does Rust manage lifetimes in function signatures?
By using lifetime annotations
By relying on garbage collection
Through automatic lifetime inference
By specifying the lifetime of a variable
13.
What is the purpose of the `thread::spawn` function in Rust?
To create a new thread
To spawn a new process
To handle exceptions in a separate thread
To define a module
14.
What is the purpose of the `Cell` type in Rust?
To manage the lifetime of a variable
To represent a cell in a data structure
To handle ownership of a value
To provide interior mutability for a value
15.
What is the purpose of the `cfg` attribute in Rust?
To specify a lifetime
To declare a constant
To define a structure
To conditionally compile code
16.
What is the role of the `Drop` trait in Rust?
To specify a lifetime
To handle exceptions in Rust
To represent a numeric type
To define custom cleanup code when a value goes out of scope
17.
What does the `Cow` type in Rust stand for?
Change on Write
Copy on Write
Create on Write
Clone on Write
18.
How does Rust handle the absence of a value without using `Option`?
By using the `Result` type
By returning a default value
By panicking
By relying on garbage collection
19.
How does Rust prevent data races with its ownership system?
By allowing only one mutable reference at a time
By using global locks and mutexes
By relying on garbage collection
By enforcing runtime checks
20.
What does the `const fn` keyword combination indicate in Rust?
A function with no parameters
A constant value
A compile-time evaluatable function
A function with flexible lifetime