Skip to content

Commit ad38efe

Browse files
committed
conventions: Codify use of newtypes
1 parent 5bac9df commit ad38efe

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

CONVENTIONS.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ 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+
```
2332

2433
## Bitflags
2534

@@ -30,6 +39,7 @@ We name the type for a set of constants whose element's names start with `FOO_`
3039
`FooFlags`.
3140

3241

42+
3343
## Enumerations
3444

3545
We represent sets of constants that are intended as mutually exclusive arguments

0 commit comments

Comments
 (0)