@@ -247,11 +247,11 @@ Of course, it might be bounded by the *wrong* lifetime, but this will usually
247
247
just cause a compiler error, rather than allow memory safety to be trivially
248
248
violated.
249
249
250
- Within a function, bounding lifetimes is more error-prone. The safest route
251
- is to just use a small function to ensure the lifetime is bound. However if
252
- this is unacceptable, the reference can be placed in a location with a specific
253
- lifetime. Unfortunately it's impossible to name all lifetimes involved in a
254
- function. To get around this, you can in principle use ` copy_lifetime ` , though
250
+ Within a function, bounding lifetimes is more error-prone. The safest and easiest
251
+ way to bound a lifetime is to return it from a function with a bound lifetime.
252
+ However if this is unacceptable, the reference can be placed in a location with
253
+ a specific lifetime. Unfortunately it's impossible to name all lifetimes involved
254
+ in a function. To get around this, you can in principle use ` copy_lifetime ` , though
255
255
these are unstable due to their awkward nature and questionable utility.
256
256
257
257
@@ -425,7 +425,7 @@ must be invariant to avoid lifetime smuggling.
425
425
426
426
` Fn ` is the most confusing case, largely because contravariance is easily the
427
427
most confusing kind of variance, and basically never comes up. To understand it,
428
- consider a function that * takes * a function ` len ` that takes a function ` F ` .
428
+ consider a function ` len ` that takes a function ` F ` .
429
429
430
430
``` rust
431
431
fn len <F >(func : F ) -> usize
@@ -435,8 +435,8 @@ fn len<F>(func: F) -> usize
435
435
}
436
436
```
437
437
438
- We require that F is a Fn that can take an ` &'static str ` and print a usize. Now
439
- say we have a function that can take an ` &'a str ` (for * some* 'a ). Such a function actually
438
+ We require that F is a Fn that can take an ` &'static str ` and returns a usize. Now
439
+ say we have a function that can take an ` &'a str ` (for * some* ` 'a ` ). Such a function actually
440
440
accepts * more* inputs, since ` &'static str ` is a subtype of ` &'a str ` . Therefore
441
441
` len ` should happily accept such a function!
442
442
@@ -643,8 +643,8 @@ trait Iterator {
643
643
Given this definition, Self::Item has * no* connection to ` self ` . This means
644
644
that we can call ` next ` several times in a row, and hold onto all the results
645
645
* concurrently* . This is perfectly fine for by-value iterators, which have exactly
646
- these semantics. It's also actually fine for shared references, as it's perfectly
647
- fine to grab a huge pile of shared references to the same thing (although the
646
+ these semantics. It's also actually fine for shared references, as they admit
647
+ arbitrarily many references to the same thing (although the
648
648
iterator needs to be a separate object from the thing being shared). But mutable
649
649
references make this a mess. At first glance, they might seem completely
650
650
incompatible with this API, as it would produce multiple mutable references to
0 commit comments