summary refs log tree commit diff
path: root/src/libcore/unicode
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-04-06 10:24:01 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-04-12 00:13:53 +0200
commitd4ed1e6fa4978141408ef01d0d35c7bd142dd164 (patch)
tree4943e332478a1658581eb8872ff7be92b1d1b499 /src/libcore/unicode
parent0d9afcd9b9f881545c8b722855f7e39361495d27 (diff)
downloadrust-d4ed1e6fa4978141408ef01d0d35c7bd142dd164.tar.gz
rust-d4ed1e6fa4978141408ef01d0d35c7bd142dd164.zip
Merge unstable Utf16Encoder into EncodeUtf16
Diffstat (limited to 'src/libcore/unicode')
-rw-r--r--src/libcore/unicode/mod.rs58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/libcore/unicode/mod.rs b/src/libcore/unicode/mod.rs
index 3413476fd22..9ab8cb748b1 100644
--- a/src/libcore/unicode/mod.rs
+++ b/src/libcore/unicode/mod.rs
@@ -24,61 +24,3 @@ pub mod derived_property {
 pub mod property {
     pub use unicode::tables::property::Pattern_White_Space;
 }
-
-use iter::FusedIterator;
-
-/// Iterator adaptor for encoding `char`s to UTF-16.
-#[derive(Clone)]
-#[allow(missing_debug_implementations)]
-pub struct Utf16Encoder<I> {
-    chars: I,
-    extra: u16,
-}
-
-impl<I> Utf16Encoder<I> {
-    /// Create a UTF-16 encoder from any `char` iterator.
-    pub fn new(chars: I) -> Utf16Encoder<I>
-        where I: Iterator<Item = char>
-    {
-        Utf16Encoder {
-            chars,
-            extra: 0,
-        }
-    }
-}
-
-impl<I> Iterator for Utf16Encoder<I>
-    where I: Iterator<Item = char>
-{
-    type Item = u16;
-
-    #[inline]
-    fn next(&mut self) -> Option<u16> {
-        if self.extra != 0 {
-            let tmp = self.extra;
-            self.extra = 0;
-            return Some(tmp);
-        }
-
-        let mut buf = [0; 2];
-        self.chars.next().map(|ch| {
-            let n = ch.encode_utf16(&mut buf).len();
-            if n == 2 {
-                self.extra = buf[1];
-            }
-            buf[0]
-        })
-    }
-
-    #[inline]
-    fn size_hint(&self) -> (usize, Option<usize>) {
-        let (low, high) = self.chars.size_hint();
-        // every char gets either one u16 or two u16,
-        // so this iterator is between 1 or 2 times as
-        // long as the underlying iterator.
-        (low, high.and_then(|n| n.checked_mul(2)))
-    }
-}
-
-impl<I> FusedIterator for Utf16Encoder<I>
-    where I: FusedIterator<Item = char> {}