fix: correct , to .

This commit is contained in:
katopz 2022-11-07 11:02:49 +07:00
parent 1a5bdaaf77
commit 14a2600176
No known key found for this signature in database
GPG Key ID: C17323088013E8B8
2 changed files with 11 additions and 11 deletions

View File

@ -39,7 +39,7 @@ fn main() {
}
```
1,🌟
1. 🌟
```rust,editable
/* Annotate struct with lifetime:
1. `r` and `s` must have different lifetimes
@ -55,7 +55,7 @@ fn main() {
```
2,🌟🌟
2. 🌟🌟
```rust,editable
/* Adding trait bounds to make it work */
struct ImportantExcerpt<'a> {
@ -74,7 +74,7 @@ fn main() {
}
```
3,🌟🌟
3. 🌟🌟
```rust,editable
/* Adding trait bounds to make it work */
fn f<'a, 'b>(x: &'a i32, mut y: &'b i32) {
@ -100,7 +100,7 @@ and could then be used to compare a `&'a T` with any lifetime to an `i32`.
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.
4,🌟🌟🌟
4. 🌟🌟🌟
```rust,editable
/* Adding HRTB to make it work!*/
fn call_on_ref_zero<'a, F>(f: F) where F: Fn(&'a i32) {
@ -187,7 +187,7 @@ fn main() {
```
5,🌟🌟
5. 🌟🌟
```rust,editable
/* Make it work by reordering some code */
fn main() {
@ -235,7 +235,7 @@ struct Ref<'a, T> {
## A difficult exercise
6,🌟🌟🌟🌟
6. 🌟🌟🌟🌟
```rust,editable
/* Make it work */
struct Interface<'a> {

View File

@ -32,7 +32,7 @@ fn need_static(r : &'static str) {
}
```
2, 🌟🌟🌟🌟 Another way to make `'static` lifetime is using `Box::leak`
2. 🌟🌟🌟🌟 Another way to make `'static` lifetime is using `Box::leak`
```rust,editable
#[derive(Debug)]
struct Config {
@ -59,7 +59,7 @@ fn main() {
}
```
3, 🌟 `&'static` only indicates that the data can live forever, not the reference. The latter one will be constrained by its scope.
3. 🌟 `&'static` only indicates that the data can live forever, not the reference. The latter one will be constrained by its scope.
```rust,editable
fn main() {
{
@ -75,7 +75,7 @@ fn main() {
}
```
4, `&'static` can be coerced to a shorter lifetime.
4. `&'static` can be coerced to a shorter lifetime.
**Example**
```rust,editable
@ -112,7 +112,7 @@ As a trait bound, it means the type does not contain any non-static references.
It's important to understand this means that any owned data always passes a `'static `lifetime bound, but a reference to that owned data generally does not.
5,🌟🌟
5. 🌟🌟
```rust,editable
/* Make it work */
use std::fmt::Debug;
@ -147,7 +147,7 @@ fn main() {
```
6,🌟🌟🌟
6. 🌟🌟🌟
```rust,editable
use std::fmt::Display;