From 6f0bcde6192576bd1fe55a4ab35ee441748916db Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Fri, 4 Mar 2016 20:02:47 -0500 Subject: conventions: Codify use of newtypes --- CONVENTIONS.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'CONVENTIONS.md') 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 -- cgit v1.2.3