diff options
author | Kamal Marhubi <kamal@marhubi.com> | 2016-03-04 20:02:47 -0500 |
---|---|---|
committer | Kamal Marhubi <kamal@marhubi.com> | 2016-03-11 11:40:22 -0500 |
commit | 6f0bcde6192576bd1fe55a4ab35ee441748916db (patch) | |
tree | c5dc83d48721d3847285eee527b2b8efe55b9229 /CONVENTIONS.md | |
parent | 5bac9df47cfc53b54f0013247ec42387ee67fffa (diff) | |
download | nix-6f0bcde6192576bd1fe55a4ab35ee441748916db.zip |
conventions: Codify use of newtypes
Diffstat (limited to 'CONVENTIONS.md')
-rw-r--r-- | CONVENTIONS.md | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/CONVENTIONS.md b/CONVENTIONS.md index 3b0a0875..068f1e45 100644 --- a/CONVENTIONS.md +++ b/CONVENTIONS.md @@ -19,7 +19,18 @@ We use the functions exported from [libc][libc] instead of writing our own `extern` declarations. We use the `struct` definitions from [libc][libc] internally instead of writing -our own. +our own. If we want to add methods to a libc type, we use the newtype pattern. +For example, + +```rust +pub struct SigSet(libc::sigset_t); + +impl SigSet { + ... +} +``` + +When creating newtypes, we use Rust's `CamelCase` type naming convention. ## Bitflags |