Description
Howdy 👋
@stevenhartley recently brought up on a PR going into up-client-zenoh-rust
that the other language libs implement their UUID builder / factory as singletons to avoid an end-user accidentally foot-gunning themselves by using multiple UUIDBuilder within one uE.
He asked why the same wasn't done in up-rust
. I had my thoughts as to why:
Making it a singleton in Rust forces upon the end user a certain way of interacting with the singleton and there are multiple (reasonable) ways of doing this in Rust. However, maybe it makes sense to give a "simple" path to an end-user not foot-gunning themselves with multiple UUIDBuilder, but allow the possibility for an advanced user to ensure it's a singleton themselves?
A couple of reasonable ways of doing this in Rust:
- lazy_static
- once_cell
Looking to hear feedback on this, hopefully from @sophokles73, @AnotherDaniel, and @evshary