James Gao wrote:
IMO, a lifetime is a compile-time constant bound to some run-time
variable.
This is not correct---or, at least, this is not what the Rust compiler
implements. The names of lifetimes and the names of variables are not
related.
Based on the new popular syntax, we have some shorthand:
* **'x* means lifetime of x
*
* *'x.fieldA.subFieldB* means lifetime of x.fieldA.subfieldB
* *'x ^ 'y* means intersection of lifetimes binding x and y
* *['x.*]* means lifetime vector of x's deep fields, this sigil is
only for easy description.
Likewise, this is incorrect as is what follows Lifetime names are not
expressions, though that would be a reasonable way to construct a
system. We often use the same names for lifetimes and variables but
that is to suggest a relationship, it does not create one.
For example, the following definitions of `foo()` are all valid and
equivalent (using the proposed syntax):
struct Foo { f: int }
fn foo(v: &'a Foo) -> &'a int { &v.f }
fn foo(v: &'b Foo) -> &'b int { &v.f }
fn foo(v: &'v Foo) -> &'v int { &v.f }
Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev