Skip to content

Commit 2ba048e

Browse files
authored
Merge pull request #1378 from xiaochuanyu/remove-lifetime-from-struct-example
Avoid lifetime annotation in struct example
2 parents 41ad35a + a025bdf commit 2ba048e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/custom_types/structs.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ There are three types of structures ("structs") that can be created using the
99

1010
```rust,editable
1111
#[derive(Debug)]
12-
struct Person<'a> {
13-
// The 'a defines a lifetime
14-
name: &'a str,
12+
struct Person {
13+
name: String,
1514
age: u8,
1615
}
1716
@@ -38,7 +37,7 @@ struct Rectangle {
3837
3938
fn main() {
4039
// Create struct with field init shorthand
41-
let name = "Peter";
40+
let name = String::from("Peter");
4241
let age = 27;
4342
let peter = Person { name, age };
4443
@@ -93,9 +92,8 @@ fn main() {
9392

9493
### See also:
9594

96-
[`attributes`][attributes], [lifetime][lifetime] and [destructuring][destructuring]
95+
[`attributes`][attributes], and [destructuring][destructuring]
9796

9897
[attributes]: ../attribute.md
9998
[c_struct]: https://en.wikipedia.org/wiki/Struct_(C_programming_language)
10099
[destructuring]: ../flow_control/match/destructuring.md
101-
[lifetime]: ../scope/lifetime.md

0 commit comments

Comments
 (0)