
Databases
Newtypes for Database IDs in Rust to Stop Mixing Them Up
Wrap IDs in tiny types so a UserId cannot be passed where an OrderId is expected. Derive sqlx::Type and Serde with transparent, and keep the cost at zero.
2 min read
Tag
1 post

Wrap IDs in tiny types so a UserId cannot be passed where an OrderId is expected. Derive sqlx::Type and Serde with transparent, and keep the cost at zero.