Skip to content

Commit 82d75cf

Browse files
authored
Merge pull request #1062 from tlyu/lifetime-bounds-wording
fix wording/punctuation in "Lifetime bounds"
2 parents 6a532e1 + f5088ea commit 82d75cf

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/trait-bounds.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ Trait and lifetime bounds are also used to name [trait objects].
102102

103103
## Lifetime bounds
104104

105-
Lifetime bounds can be applied to types or other lifetimes. The bound `'a: 'b`
106-
is usually read as `'a` *outlives* `'b`. `'a: 'b` means that `'a` lasts longer
107-
than `'b`, so a reference `&'a ()` is valid whenever `&'b ()` is valid.
105+
Lifetime bounds can be applied to types or to other lifetimes.
106+
The bound `'a: 'b` is usually read as `'a` *outlives* `'b`.
107+
`'a: 'b` means that `'a` lasts at least as long as `'b`, so a reference `&'a ()` is valid whenever `&'b ()` is valid.
108108

109109
```rust
110110
fn f<'a, 'b>(x: &'a i32, mut y: &'b i32) where 'a: 'b {
@@ -113,9 +113,8 @@ fn f<'a, 'b>(x: &'a i32, mut y: &'b i32) where 'a: 'b {
113113
}
114114
```
115115

116-
`T: 'a` means that all lifetime parameters of `T` outlive `'a`. For example if
117-
`'a` is an unconstrained lifetime parameter then `i32: 'static` and
118-
`&'static str: 'a` are satisfied but `Vec<&'a ()>: 'static` is not.
116+
`T: 'a` means that all lifetime parameters of `T` outlive `'a`.
117+
For example, if `'a` is an unconstrained lifetime parameter, then `i32: 'static` and `&'static str: 'a` are satisfied, but `Vec<&'a ()>: 'static` is not.
119118

120119
## Higher-ranked trait bounds
121120

@@ -136,8 +135,7 @@ impl<'a> PartialEq<i32> for &'a T {
136135

137136
and could then be used to compare a `&'a T` with any lifetime to an `i32`.
138137

139-
Only a higher-ranked bound can be used here as the lifetime of the reference is
140-
shorter than a lifetime parameter on the function:
138+
Only a higher-ranked bound can be used here, because the lifetime of the reference is shorter than any possible lifetime parameter on the function:
141139

142140
```rust
143141
fn call_on_ref_zero<F>(f: F) where for<'a> F: Fn(&'a i32) {
@@ -146,7 +144,7 @@ fn call_on_ref_zero<F>(f: F) where for<'a> F: Fn(&'a i32) {
146144
}
147145
```
148146

149-
Higher-ranked lifetimes may also be specified just before the trait, the only
147+
Higher-ranked lifetimes may also be specified just before the trait: the only
150148
difference is the scope of the lifetime parameter, which extends only to the
151149
end of the following trait instead of the whole bound. This function is
152150
equivalent to the last one.

0 commit comments

Comments
 (0)