Join Nostr
2026-10-22 20:21:04 UTC

Shane Celis on Nostr: Yet another reason to praise `Cow`. This function converts bytes to doubles returning ...

Yet another reason to praise `Cow`. This function converts bytes to doubles returning a `Vec<f64>`. But why allocate when you can just re-interpret and return a `&[f64]`? That's great so long as your bytes and platform have endian agreement. But what can you do when sometimes you can re-interpret the bytes in memory and sometimes you can't? That's where `Cow` comes in. It let's you borrow when you can, and own when you must.

#rustlang