@@ -22,19 +22,17 @@ use ty::Unsafe;
2222/// A mutable memory location that admits only `Pod` data.
2323pub struct Cell < T > {
2424 priv value : Unsafe < T > ,
25- priv marker1 : marker:: InvariantType < T > ,
26- priv marker2 : marker:: NoFreeze ,
27- priv marker3 : marker:: NoShare ,
25+ priv marker1 : marker:: NoFreeze ,
26+ priv marker2 : marker:: NoShare ,
2827}
2928
3029impl < T : Pod > Cell < T > {
3130 /// Creates a new `Cell` containing the given value.
3231 pub fn new ( value : T ) -> Cell < T > {
3332 Cell {
34- value : Unsafe { value : value, marker1 : marker:: InvariantType :: < T > } ,
35- marker1 : marker:: InvariantType :: < T > ,
36- marker2 : marker:: NoFreeze ,
37- marker3 : marker:: NoShare ,
33+ value : Unsafe :: new ( value) ,
34+ marker1 : marker:: NoFreeze ,
35+ marker2 : marker:: NoShare ,
3836 }
3937 }
4038
@@ -75,10 +73,9 @@ impl<T: fmt::Show> fmt::Show for Cell<T> {
7573pub struct RefCell < T > {
7674 priv value : Unsafe < T > ,
7775 priv borrow : BorrowFlag ,
78- priv marker1 : marker:: InvariantType < T > ,
79- priv marker2 : marker:: NoFreeze ,
80- priv marker3 : marker:: NoPod ,
81- priv marker4 : marker:: NoShare ,
76+ priv marker1 : marker:: NoFreeze ,
77+ priv marker2 : marker:: NoPod ,
78+ priv marker3 : marker:: NoShare ,
8279}
8380
8481// Values [1, MAX-1] represent the number of `Ref` active
@@ -91,11 +88,10 @@ impl<T> RefCell<T> {
9188 /// Create a new `RefCell` containing `value`
9289 pub fn new ( value : T ) -> RefCell < T > {
9390 RefCell {
94- marker1 : marker:: InvariantType :: < T > ,
95- marker2 : marker:: NoFreeze ,
96- marker3 : marker:: NoPod ,
97- marker4 : marker:: NoShare ,
98- value : Unsafe { value : value, marker1 : marker:: InvariantType :: < T > } ,
91+ marker1 : marker:: NoFreeze ,
92+ marker2 : marker:: NoPod ,
93+ marker3 : marker:: NoShare ,
94+ value : Unsafe :: new ( value) ,
9995 borrow : UNUSED ,
10096 }
10197 }
@@ -173,28 +169,6 @@ impl<T> RefCell<T> {
173169 }
174170 }
175171
176- /// Immutably borrows the wrapped value and applies `blk` to it.
177- ///
178- /// # Failure
179- ///
180- /// Fails if the value is currently mutably borrowed.
181- #[ inline]
182- pub fn with < U > ( & self , blk: |& T | -> U ) -> U {
183- let ptr = self . borrow ( ) ;
184- blk ( ptr. get ( ) )
185- }
186-
187- /// Mutably borrows the wrapped value and applies `blk` to it.
188- ///
189- /// # Failure
190- ///
191- /// Fails if the value is currently borrowed.
192- #[ inline]
193- pub fn with_mut < U > ( & self , blk: |& mut T | -> U ) -> U {
194- let mut ptr = self . borrow_mut ( ) ;
195- blk ( ptr. get ( ) )
196- }
197-
198172 /// Sets the value, replacing what was there.
199173 ///
200174 /// # Failure
@@ -372,43 +346,6 @@ mod test {
372346 assert ! ( x. try_borrow_mut( ) . is_none( ) ) ;
373347 }
374348
375- #[ test]
376- fn with_ok ( ) {
377- let x = RefCell :: new ( 0 ) ;
378- assert_eq ! ( 1 , x. with( |x| * x+1 ) ) ;
379- }
380-
381- #[ test]
382- #[ should_fail]
383- fn mut_borrow_with ( ) {
384- let x = RefCell :: new ( 0 ) ;
385- let _b1 = x. borrow_mut ( ) ;
386- x. with ( |x| * x+1 ) ;
387- }
388-
389- #[ test]
390- fn borrow_with ( ) {
391- let x = RefCell :: new ( 0 ) ;
392- let _b1 = x. borrow ( ) ;
393- assert_eq ! ( 1 , x. with( |x| * x+1 ) ) ;
394- }
395-
396- #[ test]
397- fn with_mut_ok ( ) {
398- let x = RefCell :: new ( 0 ) ;
399- x. with_mut ( |x| * x += 1 ) ;
400- let b = x. borrow ( ) ;
401- assert_eq ! ( 1 , * b. get( ) ) ;
402- }
403-
404- #[ test]
405- #[ should_fail]
406- fn borrow_with_mut ( ) {
407- let x = RefCell :: new ( 0 ) ;
408- let _b = x. borrow ( ) ;
409- x. with_mut ( |x| * x += 1 ) ;
410- }
411-
412349 #[ test]
413350 #[ should_fail]
414351 fn discard_doesnt_unborrow ( ) {
0 commit comments