File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,26 @@ struct Foo {
241241For ` .md ` and ` .adoc ` files, prefer a sentence-per-line format, don't wrap lines.
242242If the line is too long, you want to split the sentence in two :-)
243243
244+ ## Preconditions
245+
246+ Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee):
247+
248+ ``` rust
249+ // Good
250+ fn frbonicate (walrus : Walrus ) {
251+ ...
252+ }
253+
254+ // Not as good
255+ fn frobnicate (walrus : Option <Walrus >) {
256+ let walrus = match walrus {
257+ Some (it ) => it ,
258+ None => return ,
259+ };
260+ ...
261+ }
262+ ```
263+
244264# Architecture Invariants
245265
246266This section tries to document high-level design constraints, which are not
You can’t perform that action at this time.
0 commit comments