about summary refs log tree commit diff
path: root/src/libstd_unicode
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-03-01 23:01:09 +0100
committerSimon Sapin <simon.sapin@exyr.org>2017-03-02 17:45:50 +0100
commit24b39c51af8b7320fd825a66a239a497f20b0ece (patch)
tree2d085a13de1541bb72d186096e7dc695bc21bda5 /src/libstd_unicode
parent031f9b15df3df5da19b64a1f824463053898d021 (diff)
downloadrust-24b39c51af8b7320fd825a66a239a497f20b0ece.tar.gz
rust-24b39c51af8b7320fd825a66a239a497f20b0ece.zip
Remove std_unicode::str::is_utf16
It was only accessible through the `#[unstable]` crate std_unicode.

It has never been used in the compiler or standard library
since 47e7a05a28c9662159af2d2e0f2b7efc13fa09cb added it in 2012
“for OS API interop”.
It can be replaced with a one-liner:

```rust
fn is_utf16(slice: &[u16]) -> bool {
    std::char::decode_utf16(s.iter().cloned()).all(|r| r.is_ok())
}
```
Diffstat (limited to 'src/libstd_unicode')
-rw-r--r--src/libstd_unicode/lib.rs1
-rw-r--r--src/libstd_unicode/u_str.rs22
2 files changed, 0 insertions, 23 deletions
diff --git a/src/libstd_unicode/lib.rs b/src/libstd_unicode/lib.rs
index 1adf00e40f1..7e5ab1a54ab 100644
--- a/src/libstd_unicode/lib.rs
+++ b/src/libstd_unicode/lib.rs
@@ -47,7 +47,6 @@ pub mod char;
 #[allow(deprecated)]
 pub mod str {
     pub use u_str::{SplitWhitespace, UnicodeStr};
-    pub use u_str::is_utf16;
     pub use u_str::Utf16Encoder;
 }
 
diff --git a/src/libstd_unicode/u_str.rs b/src/libstd_unicode/u_str.rs
index 0ca6db9b0de..3c02ea82d2a 100644
--- a/src/libstd_unicode/u_str.rs
+++ b/src/libstd_unicode/u_str.rs
@@ -77,28 +77,6 @@ impl UnicodeStr for str {
     }
 }
 
-/// Determines if a vector of `u16` contains valid UTF-16
-pub fn is_utf16(v: &[u16]) -> bool {
-    let mut it = v.iter();
-    macro_rules! next { ($ret:expr) => {
-            match it.next() { Some(u) => *u, None => return $ret }
-        }
-    }
-    loop {
-        let u = next!(true);
-
-        match char::from_u32(u as u32) {
-            Some(_) => {}
-            None => {
-                let u2 = next!(false);
-                if u < 0xD7FF || u > 0xDBFF || u2 < 0xDC00 || u2 > 0xDFFF {
-                    return false;
-                }
-            }
-        }
-    }
-}
-
 /// Iterator adaptor for encoding `char`s to UTF-16.
 #[derive(Clone)]
 pub struct Utf16Encoder<I> {