Jan :rust: :ferris: on Nostr: #Rust's module system is actually amazing! ✨ 🎡 Let's say we have a module `foo` ...
#Rust's module system is actually amazing! ✨ 🎡
Let's say we have a module `foo` that can create `Foo`s in different ways. Yes, that's it - it can only create `Foo`s.
But `Foo`s should also be able to `dance` and `twinkle`.
So we create two other modules `dance` and `twinkle` and `impl Foo` in each of them, so `Foo` can dance and twinkle.
But `Bar` can also dance - so we `impl Bar` in `dance` as well.
Do you see a pattern? You organize (primarily) by _behaviour_, not data.
#RustLang
Published at
2024-10-19 10:44:05Event JSON
{
"id": "98b743a4465d014353d165b36902179d8519313d3862ed30ba0569d1ff43f7f1",
"pubkey": "54e8f9627abcf50f226918fafe608036f993cc5392b365341dd679873150d5c8",
"created_at": 1729334645,
"kind": 1,
"tags": [
[
"t",
"Rust"
],
[
"t",
"rustlang"
],
[
"proxy",
"https://floss.social/users/janriemer/statuses/113333675308898065",
"activitypub"
]
],
"content": "#Rust's module system is actually amazing! ✨ 🎡 \n\nLet's say we have a module `foo` that can create `Foo`s in different ways. Yes, that's it - it can only create `Foo`s.\n\nBut `Foo`s should also be able to `dance` and `twinkle`.\n\nSo we create two other modules `dance` and `twinkle` and `impl Foo` in each of them, so `Foo` can dance and twinkle.\n\nBut `Bar` can also dance - so we `impl Bar` in `dance` as well.\n\nDo you see a pattern? You organize (primarily) by _behaviour_, not data.\n\n#RustLang",
"sig": "b6269f7d268537e34e8cf67d6a947a1e5c1ce7fbcc6979d857e1b7ef921663a84a5d1dcdabfb1bcc3433a36d07be44716feb45e0796e17f8039ecd88c7bd0542"
}