Does <'a, 'b: 'a> mean that the lifetime 'b must outlive the lifetime 'a?

前端 未结 2 1649
抹茶落季
抹茶落季 2020-12-10 02:30

I want to implement a builder similar to the debug builders defined by the standard library. They are defined using structures like the following:

struct Deb         


        
相关标签:
2条回答
  • 2020-12-10 02:50

    Yes, you're broadly right.

    A bound <...: 'a> means that ... (either a type or another lifetime) needs to be able to outlive 'a. E.g. 'b: 'a means that "'b must live at least as long as 'a" (not strictly outlives, though: they can be the same).

    0 讨论(0)
  • 2020-12-10 03:00

    The colon is read "outlives", so

    'long: 'short
    

    is read "'long outlives 'short".

    As for an official doc on the topic, the only place I've seen it documented so far is in the RFC on lifetime bounds.

    0 讨论(0)
提交回复
热议问题