Menu

1 / 2

[RustGuide] 10.8. Lifetime Annotations in Method Definitions and Static Lifetime

DEV Community·SomeB1oody·7 months ago
#H9rPkxBm
#rust#programming#learning#software#lifetime
Reading 0:00
15s threshold

If you find this helpful, please like, bookmark, and follow. To keep learning along, follow this series.

10.8.1 Lifetime Annotations in Method Definitions

Do you still remember the three lifetime elision rules mentioned in the previous article, 10.7. Input and Output Lifetimes and the 3 Rules?

Rule 1: Each reference parameter gets its own lifetime. A single-parameter function has one lifetime, a two-parameter function has two lifetimes, and so on.

Rule 2: If there is exactly one input lifetime parameter, that lifetime is assigned to all output lifetime parameters.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.