Skip to content

Commit

Permalink
guide: type aliases
Browse files Browse the repository at this point in the history
closes #32
cc #89
  • Loading branch information
nrc committed Nov 13, 2017
1 parent 35bff4c commit 3b7c081
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions guide/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,33 @@ where
}
```


### Type aliases

Type aliases should generally be kept on one line. If necessary to break the
line, do so after the `=`; the right-hand-side should be block indented:

```rust
pub type Foo = Bar<T>;

// If multi-line is required
type VeryLongType<T, U: SomeBound> =
AnEvenLongerType<T, U, Foo<T>>;
```

Where possible avoid `where` clauses and keep type constraints inline. Where
that is not possible split the line before and after the `where` clause (and
split the `where` clause as normal), e.g.,

```rust
type VeryLongType<T, U>
where
T: U::AnAssociatedType,
U: SomeBound,
= AnEvenLongerType<T, U, Foo<T>>;
```


### extern items

When writing extern items (such as `extern "C" fn`), always be explicit about
Expand Down

0 comments on commit 3b7c081

Please sign in to comment.