Why Nostr? What is Njump?
2024-12-01 19:13:09

mcc on Nostr: In Rust, is there any reason at all to make a Option<Vec<Thing>> instead of a ...

In Rust, is there any reason at all to make a Option<Vec<Thing>> instead of a Vec<Thing> if the semantics of "None" here just mean "there are no Things"? Like if you create and never populate an empty vec that's never gonna allocate on the heap right?

I guess one way of looking at it might be that Option<Vec<>> might be taking a small performance hit in exchange for the ability to catch None via match {}, but that probably is only ergonomics
Author Public Key
npub15vtzh9eq7663ttzt6gk4af9t7ru97459zvxu5s85dlngfl59kf2srvx8ma