diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2015-08-19 16:03:59 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2015-08-22 13:58:39 +0200 |
| commit | c408b7863389aa2bdb253ffa363e693bcd02439f (patch) | |
| tree | d24554daf2d34ade8df07a7a68c4a5ced316cf0b /src/liballoc/boxed.rs | |
| parent | 94ee3b5a54a9f4965b82f5e4eda512966e96ac63 (diff) | |
| download | rust-c408b7863389aa2bdb253ffa363e693bcd02439f.tar.gz rust-c408b7863389aa2bdb253ffa363e693bcd02439f.zip | |
Move the Borrow and BorrowMut traits to libcore.
Diffstat (limited to 'src/liballoc/boxed.rs')
| -rw-r--r-- | src/liballoc/boxed.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index e3019f952fe..a6e0f3a9bd9 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -57,6 +57,7 @@ use heap; use raw_vec::RawVec; use core::any::Any; +use core::borrow; use core::cmp::Ordering; use core::fmt; use core::hash::{self, Hash}; @@ -562,3 +563,10 @@ impl<T: Clone> Clone for Box<[T]> { } } +impl<T: ?Sized> borrow::Borrow<T> for Box<T> { + fn borrow(&self) -> &T { &**self } +} + +impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> { + fn borrow_mut(&mut self) -> &mut T { &mut **self } +} |
