From 5e8d2736db2a2fbb3e2f4a408c462d9c43111b51 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 16 Sep 2014 14:26:03 -0400 Subject: [PATCH] Permit multiple lifetime bounds on parameter types. --- ...0049-bounds-on-object-and-generic-types.md | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/active/0049-bounds-on-object-and-generic-types.md b/active/0049-bounds-on-object-and-generic-types.md index 5fc8dd1508f..558cacea78f 100644 --- a/active/0049-bounds-on-object-and-generic-types.md +++ b/active/0049-bounds-on-object-and-generic-types.md @@ -69,24 +69,6 @@ declared: Here, the constraint `T:'a` indicates that the data being iterated over must live at least as long as the collection (logically enough). -### At most one explicit lifetime bound is permitted - -For simplicity, we permit at most one *explicit* lifetime bound on any -given parameter type. That means that the following function is illegal: - - fn foo<'a,'b,A:'a+'b>() { ... } - -Remember that if there are multiple lifetime bounds, it implies that -all of them must hold. That means that if, in fact, `A` outlives both -`'a` and `'b` then either one of them is shorter than the other, the -two are the same, or there is a third lifetime that outlives them -both. Therefore, the function above can be rewritten as follows (using -explicit lifetime bounds, specified below): - - fn foo<'a,'b,'c:'a+'b,A:'c>() { ... } - -As far as I know, this situation has not arisen once in the codebase. - ## Lifetime bounds on object types Like parameters, all object types have a lifetime bound. Unlike @@ -113,9 +95,9 @@ Here are some examples: // IsStatic+'a 'static+'a // IsStatic+Is<'a>+'b 'static,'a,'b -In general no object type is permitted to have zero bounds. Therefore, -if an object type with no derivable bounds appears, we will supply a -default lifetime using the normal rules: +Object types must have exactly one bound -- zero bounds is not +acceptable. Therefore, if an object type with no derivable bounds +appears, we will supply a default lifetime using the normal rules: trait Writer { /* no derivable bounds */ } struct Foo<'a> {