@@ -3,7 +3,7 @@ mod impls;
3
3
mod lazy;
4
4
mod once;
5
5
6
- use crate :: analyzer:: Analyzer ;
6
+ use crate :: { analyzer:: Analyzer , entity :: Entity } ;
7
7
pub use collector:: * ;
8
8
pub use lazy:: * ;
9
9
pub use once:: * ;
@@ -14,39 +14,30 @@ pub trait ConsumableTrait<'a>: Debug {
14
14
fn consume ( & self , analyzer : & mut Analyzer < ' a > ) ;
15
15
}
16
16
17
- pub trait IntoConsumable < ' a > {
18
- fn into_consumable ( self , allocator : & ' a Allocator ) -> Consumable < ' a > ;
19
- }
20
-
21
- pub trait ConsumeTrait < ' a > : Debug + IntoConsumable < ' a > {
17
+ pub trait ConsumeTrait < ' a > : Debug {
22
18
fn consume ( & self , analyzer : & mut Analyzer < ' a > ) ;
23
- }
24
-
25
- impl < ' a , T : ConsumableTrait < ' a > + ' a > IntoConsumable < ' a > for T {
26
- fn into_consumable ( self , allocator : & ' a Allocator ) -> Consumable < ' a > {
27
- Consumable ( allocator. alloc ( self ) )
28
- }
19
+ fn uniform ( self , allocator : & ' a Allocator ) -> Consumable < ' a > ;
29
20
}
30
21
31
22
impl < ' a , T : ConsumableTrait < ' a > + ' a > ConsumeTrait < ' a > for T {
32
23
fn consume ( & self , analyzer : & mut Analyzer < ' a > ) {
33
24
self . consume ( analyzer) ;
34
25
}
26
+ fn uniform ( self , allocator : & ' a Allocator ) -> Consumable < ' a > {
27
+ Consumable ( allocator. alloc ( self ) )
28
+ }
35
29
}
36
30
37
31
#[ derive( Debug , Clone , Copy ) ]
38
32
pub struct Consumable < ' a > ( pub & ' a ( dyn ConsumableTrait < ' a > + ' a ) ) ;
39
33
40
- impl < ' a > IntoConsumable < ' a > for Consumable < ' a > {
41
- fn into_consumable ( self , _allocator : & ' a Allocator ) -> Consumable < ' a > {
42
- self
43
- }
44
- }
45
-
46
34
impl < ' a > ConsumeTrait < ' a > for Consumable < ' a > {
47
35
fn consume ( & self , analyzer : & mut Analyzer < ' a > ) {
48
36
self . 0 . consume ( analyzer) ;
49
37
}
38
+ fn uniform ( self , _: & ' a Allocator ) -> Consumable < ' a > {
39
+ self
40
+ }
50
41
}
51
42
52
43
pub type ConsumableVec < ' a > = Vec < Consumable < ' a > > ;
0 commit comments