@@ -5,21 +5,16 @@ use crate::track::{Track, Tracked, TrackedMut, Validate};
55
66/// Ensure a type is suitable as input.
77#[ inline]
8- pub fn assert_hashable_or_trackable < In : Input > ( _: & In ) { }
8+ pub fn assert_hashable_or_trackable < ' a , In : Input < ' a > > ( _: & In ) { }
99
1010/// An input to a cached function.
1111///
1212/// This is implemented for hashable types, `Tracked<_>` types and `Args<(...)>`
1313/// types containing tuples up to length twelve.
14- pub trait Input {
14+ pub trait Input < ' a > {
1515 /// The constraints for this input.
1616 type Constraint : Default + Clone + Join + ' static ;
1717
18- /// The input with new constraints hooked in.
19- type Tracked < ' r >
20- where
21- Self : ' r ;
22-
2318 /// The extracted outer constraints.
2419 type Outer : Join < Self :: Constraint > ;
2520
@@ -34,21 +29,14 @@ pub trait Input {
3429
3530 /// Hook up the given constraint to the tracked parts of the input and
3631 /// return the result alongside the outer constraints.
37- fn retrack < ' r > (
38- self ,
39- constraint : & ' r Self :: Constraint ,
40- ) -> ( Self :: Tracked < ' r > , Self :: Outer )
32+ fn retrack ( self , constraint : & ' a Self :: Constraint ) -> ( Self , Self :: Outer )
4133 where
42- Self : ' r ;
34+ Self : Sized ;
4335}
4436
45- impl < T : Hash > Input for T {
37+ impl < ' a , T : Hash > Input < ' a > for T {
4638 // No constraint for hashed inputs.
4739 type Constraint = ( ) ;
48- type Tracked < ' r >
49- = Self
50- where
51- Self : ' r ;
5240 type Outer = ( ) ;
5341
5442 #[ inline]
@@ -65,24 +53,17 @@ impl<T: Hash> Input for T {
6553 fn replay ( & mut self , _: & Self :: Constraint ) { }
6654
6755 #[ inline]
68- fn retrack < ' r > ( self , _: & ' r ( ) ) -> ( Self :: Tracked < ' r > , Self :: Outer )
69- where
70- Self : ' r ,
71- {
56+ fn retrack ( self , _: & ' a ( ) ) -> ( Self , Self :: Outer ) {
7257 ( self , ( ) )
7358 }
7459}
7560
76- impl < ' a , T > Input for Tracked < ' a , T >
61+ impl < ' a , T > Input < ' a > for Tracked < ' a , T >
7762where
7863 T : Track + ?Sized ,
7964{
8065 // Forward constraint from `Trackable` implementation.
8166 type Constraint = <T as Validate >:: Constraint ;
82- type Tracked < ' r >
83- = Tracked < ' r , T >
84- where
85- Self : ' r ;
8667 type Outer = Option < & ' a Self :: Constraint > ;
8768
8869 #[ inline]
9778 fn replay ( & mut self , _: & Self :: Constraint ) { }
9879
9980 #[ inline]
100- fn retrack < ' r > (
101- self ,
102- constraint : & ' r Self :: Constraint ,
103- ) -> ( Self :: Tracked < ' r > , Self :: Outer )
104- where
105- Self : ' r ,
106- {
81+ fn retrack ( self , constraint : & ' a Self :: Constraint ) -> ( Self , Self :: Outer ) {
10782 let tracked = Tracked {
10883 value : self . value ,
10984 constraint : Some ( constraint) ,
@@ -113,16 +88,12 @@ where
11388 }
11489}
11590
116- impl < ' a , T > Input for TrackedMut < ' a , T >
91+ impl < ' a , T > Input < ' a > for TrackedMut < ' a , T >
11792where
11893 T : Track + ?Sized ,
11994{
12095 // Forward constraint from `Trackable` implementation.
12196 type Constraint = T :: Constraint ;
122- type Tracked < ' r >
123- = TrackedMut < ' r , T >
124- where
125- Self : ' r ;
12697 type Outer = Option < & ' a Self :: Constraint > ;
12798
12899 #[ inline]
@@ -139,13 +110,7 @@ where
139110 }
140111
141112 #[ inline]
142- fn retrack < ' r > (
143- self ,
144- constraint : & ' r Self :: Constraint ,
145- ) -> ( Self :: Tracked < ' r > , Self :: Outer )
146- where
147- Self : ' r ,
148- {
113+ fn retrack ( self , constraint : & ' a Self :: Constraint ) -> ( Self , Self :: Outer ) {
149114 let tracked = TrackedMut { value : self . value , constraint : Some ( constraint) } ;
150115 ( tracked, self . constraint )
151116 }
@@ -157,9 +122,8 @@ pub struct Args<T>(pub T);
157122macro_rules! args_input {
158123 ( $( $param: tt $alt: tt $idx: tt ) ,* ) => {
159124 #[ allow( unused_variables, non_snake_case) ]
160- impl <$( $param: Input ) ,* > Input for Args <( $( $param, ) * ) > {
125+ impl <' a , $( $param: Input < ' a> ) ,* > Input < ' a> for Args <( $( $param, ) * ) > {
161126 type Constraint = ( $( $param:: Constraint , ) * ) ;
162- type Tracked <' r> = ( $( $param:: Tracked <' r>, ) * ) where Self : ' r;
163127 type Outer = ( $( $param:: Outer , ) * ) ;
164128
165129 #[ inline]
@@ -178,15 +142,12 @@ macro_rules! args_input {
178142 }
179143
180144 #[ inline]
181- fn retrack< ' r> (
145+ fn retrack(
182146 self ,
183- constraint: & ' r Self :: Constraint ,
184- ) -> ( Self :: Tracked <' r>, Self :: Outer )
185- where
186- Self : ' r,
187- {
147+ constraint: & ' a Self :: Constraint ,
148+ ) -> ( Self , Self :: Outer ) {
188149 $( let $param = ( self . 0 ) . $idx. retrack( & constraint. $idx) ; ) *
189- ( ( $( $param. 0 , ) * ) , ( $( $param. 1 , ) * ) )
150+ ( Args ( ( $( $param. 0 , ) * ) ) , ( $( $param. 1 , ) * ) )
190151 }
191152 }
192153
0 commit comments