diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2017-03-01 23:01:09 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2017-03-02 17:45:50 +0100 |
| commit | 24b39c51af8b7320fd825a66a239a497f20b0ece (patch) | |
| tree | 2d085a13de1541bb72d186096e7dc695bc21bda5 /src/libstd_unicode | |
| parent | 031f9b15df3df5da19b64a1f824463053898d021 (diff) | |
| download | rust-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.rs | 1 | ||||
| -rw-r--r-- | src/libstd_unicode/u_str.rs | 22 |
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> { |
