Skip to content

Commit 71ce061

Browse files
igor-petrukqwandor
andauthored
Update lifetimes-data-structures.md (#224)
* Update lifetimes-data-structures.md The example is quite simple, but in it's simplicity it may raise the question why do we even need lifetimes in the structs? Isn't it obvious that the referenced value should always outlive the struct? This sentence tries to explain that more complex cases exist. * Fix typo Co-authored-by: Andrew Walbran <qwandor@google.com>
1 parent 473fd02 commit 71ce061

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ownership/lifetimes-data-structures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ fn main() {
2626
* If `text` is consumed before the end of the lifetime of `fox` (or `dog`), the borrow checker throws an error.
2727
* Types with borrowed data force users to hold on to the original data. This can be useful for creating lightweight views, but it generally makes them somewhat harder to use.
2828
* When possible, make data structures own their data directly.
29-
29+
* Some structs with multiple references inside can have more than one lifetime annotation. This can be necessary if there is a need to describe lifetime relationships between the references themselves, in addition to the lifetime of the struct itself. Those are very advanced use cases.
3030
</details>

0 commit comments

Comments
 (0)