Skip to content

Commit 14580fc

Browse files
committed
Auto merge of #291 - kamalmarhubi:newtype-convention, r=@posborne
conventions: Codify use of newtypes
2 parents 36fb651 + 6f0bcde commit 14580fc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

CONVENTIONS.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ We use the functions exported from [libc][libc] instead of writing our own
1919
`extern` declarations.
2020

2121
We use the `struct` definitions from [libc][libc] internally instead of writing
22-
our own.
22+
our own. If we want to add methods to a libc type, we use the newtype pattern.
23+
For example,
24+
25+
```rust
26+
pub struct SigSet(libc::sigset_t);
27+
28+
impl SigSet {
29+
...
30+
}
31+
```
32+
33+
When creating newtypes, we use Rust's `CamelCase` type naming convention.
2334

2435
## Bitflags
2536

0 commit comments

Comments
 (0)