How Do I … in Rust?
Discovery
… find a crate for a given purpose?
… find the latest version of a crate?
Project organization
… organize a Rust workspace?
Conveniences
… define "extension" methods on a type in another crate?
… guarantee a trait is object-safe?
static_assertions::assert_obj_safe!(MyTrait);
Error handling and debugging
… handle errors simply and correctly?
… structure errors in a public API?
… set up basic logging?
Collections
… create a fast HashMap
?
… convert from slices to fixed-length arrays?
… Implement an impl Iterator
with todo!
?
fn merge_create_accounts_results(
accounts: &[tb::Account],
results: Vec<tb::CreateAccountsResult>,
) -> impl Iterator<Item = (u128, Option<tb::Account>)> + use<'_> {
todo!(); // optional
std::iter::empty() // satisfies the type checker
}
Numerics
… convert between numeric types ideomatically?
… perform math ideomatically?
… convert between ints and bytes?
Encoding, serialization, parsing
… serialize to and from JSON?
… decide what format to use with serde
?
Time
… parse and render standard time formats?
Random numbers
… generate a strong random number?
… generate a strong random number from a seed?
… generate a fast random number from a seed?
Cryptography
… calculate a cryptographic content hash?
Parallelism and Concurrency
… initialize a global value?
todo LazyLock
, OnceLock
, and Once
.
… send messages to/from async code?
todo futures::channels
… use a thread pool?
Use rayon::ThreadPool
.
Although it has additional rayon features, it can be used as a basic thread pool.
todo example