Skip to content

Commit

Permalink
Preconditions style
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Jun 8, 2020
1 parent ee8dec5 commit cc07c82
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/dev/README.md
Expand Up @@ -241,6 +241,26 @@ struct Foo {
For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.
If the line is too long, you want to split the sentence in two :-)

## Preconditions

Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee):

```rust
// Good
fn frbonicate(walrus: Walrus) {
...
}

// Not as good
fn frobnicate(walrus: Option<Walrus>) {
let walrus = match walrus {
Some(it) => it,
None => return,
};
...
}
```

# Architecture Invariants

This section tries to document high-level design constraints, which are not
Expand Down

0 comments on commit cc07c82

Please sign in to comment.