@@ -168,6 +168,7 @@ impl<T:Copy> Cell<T> {
168
168
/// let c = Cell::new(5);
169
169
/// ```
170
170
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
171
+ #[ inline]
171
172
pub fn new ( value : T ) -> Cell < T > {
172
173
Cell {
173
174
value : UnsafeCell :: new ( value) ,
@@ -237,6 +238,7 @@ unsafe impl<T> Send for Cell<T> where T: Send {}
237
238
238
239
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
239
240
impl < T : Copy > Clone for Cell < T > {
241
+ #[ inline]
240
242
fn clone ( & self ) -> Cell < T > {
241
243
Cell :: new ( self . get ( ) )
242
244
}
@@ -245,13 +247,15 @@ impl<T:Copy> Clone for Cell<T> {
245
247
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
246
248
impl < T : Default + Copy > Default for Cell < T > {
247
249
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
250
+ #[ inline]
248
251
fn default ( ) -> Cell < T > {
249
252
Cell :: new ( Default :: default ( ) )
250
253
}
251
254
}
252
255
253
256
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
254
257
impl < T : PartialEq + Copy > PartialEq for Cell < T > {
258
+ #[ inline]
255
259
fn eq ( & self , other : & Cell < T > ) -> bool {
256
260
self . get ( ) == other. get ( )
257
261
}
@@ -295,6 +299,7 @@ impl<T> RefCell<T> {
295
299
/// let c = RefCell::new(5);
296
300
/// ```
297
301
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
302
+ #[ inline]
298
303
pub fn new ( value : T ) -> RefCell < T > {
299
304
RefCell {
300
305
value : UnsafeCell :: new ( value) ,
@@ -314,6 +319,7 @@ impl<T> RefCell<T> {
314
319
/// let five = c.into_inner();
315
320
/// ```
316
321
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
322
+ #[ inline]
317
323
pub fn into_inner ( self ) -> T {
318
324
// Since this function takes `self` (the `RefCell`) by value, the
319
325
// compiler statically verifies that it is not currently borrowed.
@@ -327,6 +333,7 @@ impl<T> RefCell<T> {
327
333
/// The returned value can be dispatched on to determine if a call to
328
334
/// `borrow` or `borrow_mut` would succeed.
329
335
#[ unstable( feature = "std_misc" ) ]
336
+ #[ inline]
330
337
pub fn borrow_state ( & self ) -> BorrowState {
331
338
match self . borrow . get ( ) {
332
339
WRITING => BorrowState :: Writing ,
@@ -344,6 +351,7 @@ impl<T> RefCell<T> {
344
351
#[ unstable( feature = "core" , reason = "may be renamed or removed" ) ]
345
352
#[ deprecated( since = "1.0.0" ,
346
353
reason = "dispatch on `cell.borrow_state()` instead" ) ]
354
+ #[ inline]
347
355
pub fn try_borrow < ' a > ( & ' a self ) -> Option < Ref < ' a , T > > {
348
356
match BorrowRef :: new ( & self . borrow ) {
349
357
Some ( b) => Some ( Ref { _value : unsafe { & * self . value . get ( ) } , _borrow : b } ) ,
@@ -387,6 +395,7 @@ impl<T> RefCell<T> {
387
395
/// assert!(result.is_err());
388
396
/// ```
389
397
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
398
+ #[ inline]
390
399
pub fn borrow < ' a > ( & ' a self ) -> Ref < ' a , T > {
391
400
match BorrowRef :: new ( & self . borrow ) {
392
401
Some ( b) => Ref {
@@ -406,6 +415,7 @@ impl<T> RefCell<T> {
406
415
#[ unstable( feature = "core" , reason = "may be renamed or removed" ) ]
407
416
#[ deprecated( since = "1.0.0" ,
408
417
reason = "dispatch on `cell.borrow_state()` instead" ) ]
418
+ #[ inline]
409
419
pub fn try_borrow_mut < ' a > ( & ' a self ) -> Option < RefMut < ' a , T > > {
410
420
match BorrowRefMut :: new ( & self . borrow ) {
411
421
Some ( b) => Some ( RefMut { _value : unsafe { & mut * self . value . get ( ) } , _borrow : b } ) ,
@@ -448,6 +458,7 @@ impl<T> RefCell<T> {
448
458
/// assert!(result.is_err());
449
459
/// ```
450
460
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
461
+ #[ inline]
451
462
pub fn borrow_mut < ' a > ( & ' a self ) -> RefMut < ' a , T > {
452
463
match BorrowRefMut :: new ( & self . borrow ) {
453
464
Some ( b) => RefMut {
@@ -475,6 +486,7 @@ unsafe impl<T> Send for RefCell<T> where T: Send {}
475
486
476
487
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
477
488
impl < T : Clone > Clone for RefCell < T > {
489
+ #[ inline]
478
490
fn clone ( & self ) -> RefCell < T > {
479
491
RefCell :: new ( self . borrow ( ) . clone ( ) )
480
492
}
@@ -483,13 +495,15 @@ impl<T: Clone> Clone for RefCell<T> {
483
495
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
484
496
impl < T : Default > Default for RefCell < T > {
485
497
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
498
+ #[ inline]
486
499
fn default ( ) -> RefCell < T > {
487
500
RefCell :: new ( Default :: default ( ) )
488
501
}
489
502
}
490
503
491
504
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
492
505
impl < T : PartialEq > PartialEq for RefCell < T > {
506
+ #[ inline]
493
507
fn eq ( & self , other : & RefCell < T > ) -> bool {
494
508
* self . borrow ( ) == * other. borrow ( )
495
509
}
@@ -500,6 +514,7 @@ struct BorrowRef<'b> {
500
514
}
501
515
502
516
impl < ' b > BorrowRef < ' b > {
517
+ #[ inline]
503
518
fn new ( borrow : & ' b Cell < BorrowFlag > ) -> Option < BorrowRef < ' b > > {
504
519
match borrow. get ( ) {
505
520
WRITING => None ,
@@ -513,6 +528,7 @@ impl<'b> BorrowRef<'b> {
513
528
514
529
#[ unsafe_destructor]
515
530
impl < ' b > Drop for BorrowRef < ' b > {
531
+ #[ inline]
516
532
fn drop ( & mut self ) {
517
533
let borrow = self . _borrow . get ( ) ;
518
534
debug_assert ! ( borrow != WRITING && borrow != UNUSED ) ;
@@ -521,6 +537,7 @@ impl<'b> Drop for BorrowRef<'b> {
521
537
}
522
538
523
539
impl < ' b > Clone for BorrowRef < ' b > {
540
+ #[ inline]
524
541
fn clone ( & self ) -> BorrowRef < ' b > {
525
542
// Since this Ref exists, we know the borrow flag
526
543
// is not set to WRITING.
@@ -561,6 +578,7 @@ impl<'b, T> Deref for Ref<'b, T> {
561
578
/// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
562
579
#[ unstable( feature = "core" ,
563
580
reason = "likely to be moved to a method, pending language changes" ) ]
581
+ #[ inline]
564
582
pub fn clone_ref < ' b , T : Clone > ( orig : & Ref < ' b , T > ) -> Ref < ' b , T > {
565
583
Ref {
566
584
_value : orig. _value ,
@@ -574,6 +592,7 @@ struct BorrowRefMut<'b> {
574
592
575
593
#[ unsafe_destructor]
576
594
impl < ' b > Drop for BorrowRefMut < ' b > {
595
+ #[ inline]
577
596
fn drop ( & mut self ) {
578
597
let borrow = self . _borrow . get ( ) ;
579
598
debug_assert ! ( borrow == WRITING ) ;
@@ -582,6 +601,7 @@ impl<'b> Drop for BorrowRefMut<'b> {
582
601
}
583
602
584
603
impl < ' b > BorrowRefMut < ' b > {
604
+ #[ inline]
585
605
fn new ( borrow : & ' b Cell < BorrowFlag > ) -> Option < BorrowRefMut < ' b > > {
586
606
match borrow. get ( ) {
587
607
UNUSED => {
@@ -674,6 +694,7 @@ impl<T> UnsafeCell<T> {
674
694
/// let uc = UnsafeCell::new(5);
675
695
/// ```
676
696
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
697
+ #[ inline]
677
698
pub fn new ( value : T ) -> UnsafeCell < T > {
678
699
UnsafeCell { value : value }
679
700
}
0 commit comments