2
2
3
3
use std:: cell:: Cell ;
4
4
use std:: mem;
5
- use std:: ops:: { Deref , DerefMut } ;
6
5
7
6
/// Type lambda application, with a lifetime.
8
7
#[ allow( unused_lifetimes) ]
@@ -15,23 +14,6 @@ pub trait LambdaL: for<'a> ApplyL<'a> {}
15
14
16
15
impl < T : for < ' a > ApplyL < ' a > > LambdaL for T { }
17
16
18
- // HACK(eddyb) work around projection limitations with a newtype
19
- // FIXME(#52812) replace with `&'a mut <T as ApplyL<'b>>::Out`
20
- pub struct RefMutL < ' a , ' b , T : LambdaL > ( & ' a mut <T as ApplyL < ' b > >:: Out ) ;
21
-
22
- impl < ' a , ' b , T : LambdaL > Deref for RefMutL < ' a , ' b , T > {
23
- type Target = <T as ApplyL < ' b > >:: Out ;
24
- fn deref ( & self ) -> & Self :: Target {
25
- self . 0
26
- }
27
- }
28
-
29
- impl < ' a , ' b , T : LambdaL > DerefMut for RefMutL < ' a , ' b , T > {
30
- fn deref_mut ( & mut self ) -> & mut Self :: Target {
31
- self . 0
32
- }
33
- }
34
-
35
17
pub struct ScopedCell < T : LambdaL > ( Cell < <T as ApplyL < ' static > >:: Out > ) ;
36
18
37
19
impl < T : LambdaL > ScopedCell < T > {
@@ -46,7 +28,7 @@ impl<T: LambdaL> ScopedCell<T> {
46
28
pub fn replace < ' a , R > (
47
29
& self ,
48
30
replacement : <T as ApplyL < ' a > >:: Out ,
49
- f : impl for <' b , ' c > FnOnce ( RefMutL < ' b , ' c , T > ) -> R ,
31
+ f : impl for <' b , ' c > FnOnce ( & ' b mut < T as ApplyL < ' c > > :: Out ) -> R ,
50
32
) -> R {
51
33
/// Wrapper that ensures that the cell always gets filled
52
34
/// (with the original state, optionally changed by `f`),
@@ -71,7 +53,7 @@ impl<T: LambdaL> ScopedCell<T> {
71
53
} ) ) ,
72
54
} ;
73
55
74
- f ( RefMutL ( put_back_on_drop. value . as_mut ( ) . unwrap ( ) ) )
56
+ f ( put_back_on_drop. value . as_mut ( ) . unwrap ( ) )
75
57
}
76
58
77
59
/// Sets the value in `self` to `value` while running `f`.
0 commit comments