Ben Ramsey on Nostr: Is there an easier way to understand Rust’s built-in data structures. I’m reading ...
Is there an easier way to understand Rust’s built-in data structures.
I’m reading code, and I see `Box<T>` (where T is obviously some other type), so I ask, “What is a box data structure?”
I look it up, and the Rust docs say, “A pointer type that uniquely owns a heap allocation of type T.”
That could be any number of data types. Why is this one called “Box?” What does it do that’s different from other pointer types? Is it the fact that it’s “uniquely owned?” What does that mean in practice?
Published at
2024-02-26 16:14:41Event JSON
{
"id": "22802a0c048e649a691074b7cf5f3cdfa903ec2c86cc777e23002a679834bed4",
"pubkey": "e653eb60b2db5edf906d354c2825bf00a80dfab1b1766cd97805155e8fcc0db3",
"created_at": 1708964081,
"kind": 1,
"tags": [
[
"proxy",
"https://phpc.social/users/ramsey/statuses/111998670057824553",
"activitypub"
]
],
"content": "Is there an easier way to understand Rust’s built-in data structures.\n\nI’m reading code, and I see `Box\u003cT\u003e` (where T is obviously some other type), so I ask, “What is a box data structure?”\n\nI look it up, and the Rust docs say, “A pointer type that uniquely owns a heap allocation of type T.”\n\nThat could be any number of data types. Why is this one called “Box?” What does it do that’s different from other pointer types? Is it the fact that it’s “uniquely owned?” What does that mean in practice?",
"sig": "07a99f421231725f38ab0e15429e6610d0695712c66df25737ab2c676fa74449e5dea685cd538eb95bd70e0c8f42f14765b4a0fc2c87f631829a85c2735ba51c"
}