fasterthanlime 🌌 on Nostr: A lesson I keep relearning in Rust is: if you have a finite number of values, you ...
A lesson I keep relearning in Rust is: if you have a finite number of values, you don't have to use a String, &str, Cow<'a, str>, smartstring type or whatever, or a structured parsed version thereof... you can just an enum
I only have maybe 15 mime types to deal with — now they're an enum, bam, they're Clone and Copy. Bye allocations!
Published at
2024-08-20 19:27:19Event JSON
{
"id": "2992ccc74cd7ee26f59872cafa496d80cdf3d23485188eb39385c8f3d1e2ebb1",
"pubkey": "a32657303ee83f9c934d058ca35a803eb5f4199368912cbba539c7f080fcb8f8",
"created_at": 1724182039,
"kind": 1,
"tags": [
[
"proxy",
"https://hachyderm.io/@fasterthanlime/112995994168830514",
"web"
],
[
"proxy",
"https://hachyderm.io/users/fasterthanlime/statuses/112995994168830514",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://hachyderm.io/users/fasterthanlime/statuses/112995994168830514",
"pink.momostr"
],
[
"-"
]
],
"content": "A lesson I keep relearning in Rust is: if you have a finite number of values, you don't have to use a String, \u0026str, Cow\u003c'a, str\u003e, smartstring type or whatever, or a structured parsed version thereof... you can just an enum\n\nI only have maybe 15 mime types to deal with — now they're an enum, bam, they're Clone and Copy. Bye allocations!",
"sig": "f433041ba3a5b1a1051f2a5338ccadfd7572a0f1430c5aa6effd34bcd40453350663d1b85599aadb137f00f55b0b481cb38157c7995883baa50705b281d503a6"
}