What's on my mind

Hacking Rust and other awesomeness.

3 January 2023

Passing Uuids

by Keith Star

I use Uuids everywhere in sarzak. Recently I accidentally passed one by value without cloning it. So I did some digging and discovered (here and here) that it’s nothing more than an array of bytes:

pub type Bytes = [u8; 16];

So that got me wondering, and I started doing some research. I found this article where the fellow was wondering the same thing as me. Based on his analysis it shouldn’t matter much which way I do it.

Personally I prefer not typing ampersands everyplace, and I think it looks nicer without. (Coding based on esthetics should probably be discouraged.) Probably the place where Uuids are used the most is in my ObjectStore table lookup macros. Since they are macros anyway, it’s easy enough to add the ampersand there. So I get to have my cake, and eat it too!

tags: rust