What is Nostr?
yosh /
npub1u86…6gze
2024-12-04 21:15:39

yosh on Nostr: My favorite string type is probably `Cow<‘static, str>`, since it only allocates if ...

My favorite string type is probably `Cow<‘static, str>`, since it only allocates if it strictly needs to. And if you use `impl Into<Cow<‘static, str>>` as a bound, you can pass both string literals and allocated strings into functions without a problem.

My least favorite string type is probably `Cow<‘static, str>`. Because seeing something like `impl Into<Cow<‘static, str>>` in a function parameter is a *lot* to read, write, and understand. And it still misses a bunch of optimizations.
Author Public Key
npub1u86g6tc80vx4zt5xv6lh5rwammfwgs7envxf9nk02aa5u59cv43shd6gze