General Rust XI
1.
How does Rust handle memory safety with ownership and borrowing?
By using a borrow checker at compile-time
By relying on garbage collection
By enforcing strict runtime checks
By automatically deallocating unused memory
2.
What is the purpose of the `std::cmp::PartialEq` trait in Rust?
To define a total ordering for values
To implement the equality operator (`==`)
To represent a numeric type
To handle exceptions
3.
How does Rust handle lifetime annotations for function parameters?
By using explicit annotations with the `'lifetime` syntax
By relying on garbage collection
By enforcing strict ownership rules
By inferring lifetimes based on the function body
4.
What is the purpose of the `std::sync::RwLock` type in Rust?
To provide a lock for shared access with multiple readers or a single writer
To represent a numeric type
To handle file I/O operations
To declare a constant
5.
How does Rust handle pattern matching with the `match` keyword?
By allowing exhaustive and comprehensive matching of values
By relying on garbage collection
By enforcing strict ownership rules
By providing automatic type conversion
6.
What is the purpose of the `std::ops::BitAnd` trait in Rust?
To declare a constant
To represent a numeric type
To handle exceptions
To overload the bitwise AND operator (`&`)
7.
How does Rust handle optional values with the `Option` type?
By using `Some` for a present value and `None` for absence
By using `Present` for a present value and `Absent` for absence
By relying on garbage collection
By enforcing strict runtime checks
8.
What is the purpose of the `std::env::args` function in Rust?
To handle file I/O operations
To create a new module
To declare a constant
To retrieve command-line arguments as strings
9.
How does Rust handle error propagation with the `Result` type?
By using the `?` operator for concise error handling
By relying on garbage collection
By enforcing strict runtime checks
By converting errors to panics
10.
What is the purpose of the `std::fs::metadata` function in Rust?
To create a new file
To declare a constant
To represent a numeric type
To retrieve metadata information about a file
11.
How does Rust handle parallelism with the `Rayon` library?
By providing a data parallelism framework for parallel iterators
By relying on garbage collection
By enforcing strict ownership rules
By using automatic parallelization
12.
What is the purpose of the `std::slice::split_at_mut` function in Rust?
To handle file I/O operations
To represent a numeric type
To declare a constant
To split a mutable slice at a specified index
13.
How does Rust handle lifetime parameters in structs?
By using explicit lifetime annotations
By relying on garbage collection
By enforcing strict ownership rules
By automatically inferring lifetimes
14.
What is the purpose of the `std::io::Read` trait in Rust?
To handle writing formatted text efficiently
To declare a constant
To define a generic type
To read bytes from a source
15.
How does Rust handle ownership and borrowing in closures?
By automatically inferring ownership and borrowing based on the closure's environment
By using the `move` keyword for ownership transfer
By relying on garbage collection
By enforcing strict runtime checks
16.
What is the purpose of the `std::path::PathBuf` type in Rust?
To represent a numeric type
To handle file I/O operations
To declare a constant
To manipulate paths as an owned, growable buffer
17.
What is the purpose of the `std::cmp::Ord` trait in Rust?
To represent a numeric type
To define a total ordering for values
To handle file I/O operations
To declare a constant
18.
How does Rust handle concurrency with the `async/await` syntax?
By providing asynchronous programming support
By using automatic reference counting
By relying on garbage collection
By enforcing strict ownership rules
19.
What is the purpose of the `std::collections::BTreeMap` type in Rust?
To represent a numeric type
To declare a constant
To store key-value pairs in a sorted order
To handle file I/O operations
20.
How does Rust implement the `Drop` trait for automatic resource cleanup?
By providing a method named `drop`
By relying on garbage collection
By using the `clean` keyword
By enforcing runtime checks