Get a report of compile performance
cargo build --timings
Golang style error handling
cargo add anyhow
// return fmt.Errorf("error, when something. Error: %v", err)
io::stdin()
.read_to_end(&mut input)
.with_context(|| "failed to read from standard in")?;
// return errors.New("error, thing happened bad bad")
io::stdin()
.read_to_end(&mut input)
.context("failed to read from standard in")?;
Random
cargo add rand
// using golang crypto/rand equivalent by default
use rand::Rng;
const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789";
fn random_string(len: usize) -> String {
let mut rng = rand::rng();
(0..len)
.map(|_| {
let idx = rng.random_range(0..CHARSET.len());
CHARSET[idx] as char
})
.collect()
}
Fancy Web Graphics
cargo add wgpu
git clone https://codeberg.org/jeremiahvaughan/base64-toggle.git
cd base64-toggle
cargo install --path .