sudo-rs icon indicating copy to clipboard operation
sudo-rs copied to clipboard

Add newtypes for UserId, GroupId and ProcessId

Open rnijveld opened this issue 2 years ago • 1 comments

We currently use type aliases, but that doesn't really add any type safety. Group ids, process ids and user ids can freely be interchanged because their definitions in libc are the same. If we use newtype wrappers (i.e. struct UserId(libc::uid_t) instead of type UserId = libc::uid_t), we can actually make a few more ensurances that they come from the right source. We should make construction of these newtypes very much explicit because of that (i.e. no From). That should prevent accidental conversion into one of the newtype definitions where it was not meant.

rnijveld avatar Sep 19 '23 14:09 rnijveld

I'm stealing this :trollface:

pvdrz avatar Sep 20 '23 20:09 pvdrz