diff options
| author | bors <bors@rust-lang.org> | 2015-08-27 00:41:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-08-27 00:41:13 +0000 |
| commit | fd302a95e1197e5f8401ecaa15f2cb0f81c830c3 (patch) | |
| tree | f067678d29ba74bb76bea9397da4b06ed975ea87 /src/liballoc | |
| parent | 80b971a9b86cf56eab5a6f707107175d4bf2bbe1 (diff) | |
| parent | 6174b8d726ed5764694e5404329d8b5e66517ed5 (diff) | |
| download | rust-fd302a95e1197e5f8401ecaa15f2cb0f81c830c3.tar.gz rust-fd302a95e1197e5f8401ecaa15f2cb0f81c830c3.zip | |
Auto merge of #27808 - SimonSapin:utf16decoder, r=alexcrichton
* Rename `Utf16Items` to `Utf16Decoder`. "Items" is meaningless. * Generalize it to any `u16` iterator, not just `[u16].iter()` * Make it yield `Result` instead of a custom `Utf16Item` enum that was isomorphic to `Result`. This enable using the `FromIterator for Result` impl. * Replace `Utf16Item::to_char_lossy` with a `Utf16Decoder::lossy` iterator adaptor. This is a [breaking change], but only for users of the unstable `rustc_unicode` crate. I’d like this functionality to be stabilized and re-exported in `std` eventually, as the "low-level equivalent" of `String::from_utf16` and `String::from_utf16_lossy` like #27784 is the low-level equivalent of #27714. CC @aturon, @alexcrichton
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 5 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 5 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index bb2daa2a1d7..b68d7976540 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -73,6 +73,7 @@ use boxed::Box; use core::sync::atomic; use core::sync::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst}; +use core::borrow; use core::fmt; use core::cmp::Ordering; use core::mem::{align_of_val, size_of_val}; @@ -1109,3 +1110,7 @@ mod tests { assert!(y.upgrade().is_none()); } } + +impl<T: ?Sized> borrow::Borrow<T> for Arc<T> { + fn borrow(&self) -> &T { &**self } +} 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 } +} diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 9649d0f71a1..b1fb5be4d21 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -158,6 +158,7 @@ use boxed::Box; #[cfg(test)] use std::boxed::Box; +use core::borrow; use core::cell::Cell; use core::cmp::Ordering; use core::fmt; @@ -1091,3 +1092,7 @@ mod tests { assert_eq!(foo, foo.clone()); } } + +impl<T: ?Sized> borrow::Borrow<T> for Rc<T> { + fn borrow(&self) -> &T { &**self } +} |
