Merge pull request #36 from dvdhrm/pr/nostd
nostd: remove left-overs from `no_std` feature flag
diff --git a/Cargo.toml b/Cargo.toml
index a0f16da..422e4f9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,6 +24,8 @@
[features]
default = []
-no_std = []
bench = []
rustc-dep-of-std = ['std', 'core', 'compiler_builtins']
+
+# Legacy, now a no-op
+no_std = []
diff --git a/scripts/unicode.py b/scripts/unicode.py
index fb05dc7..aa3c021 100755
--- a/scripts/unicode.py
+++ b/scripts/unicode.py
@@ -422,8 +422,6 @@
module.write(
"""
pub mod charwidth {
- use core::option::Option::{self, None, Some};
-
/// Returns the [UAX #11](https://www.unicode.org/reports/tr11/) based width of `c` by
/// consulting a multi-level lookup table.
/// If `is_cjk == true`, ambiguous width characters are treated as double width; otherwise,
diff --git a/src/lib.rs b/src/lib.rs
index b3d59f2..2f22613 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,8 +29,8 @@
//!
//! # features
//!
-//! unicode-width supports a `no_std` feature. This eliminates dependence
-//! on std, and instead uses equivalent functions from core.
+//! unicode-width does not depend on `std`, so it can be used in crates
+//! with the `#![no_std]` attribute.
//!
//! # crates.io
//!
diff --git a/src/tables.rs b/src/tables.rs
index 0317abb..58c215e 100644
--- a/src/tables.rs
+++ b/src/tables.rs
@@ -15,8 +15,6 @@
pub const UNICODE_VERSION: (u8, u8, u8) = (15, 1, 0);
pub mod charwidth {
- use core::option::Option::{self, None, Some};
-
/// Returns the [UAX #11](https://www.unicode.org/reports/tr11/) based width of `c` by
/// consulting a multi-level lookup table.
/// If `is_cjk == true`, ambiguous width characters are treated as double width; otherwise,
diff --git a/src/tests.rs b/src/tests.rs
index 01166ab..e242928 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -13,7 +13,7 @@
#[cfg(feature = "bench")]
use std::iter;
#[cfg(feature = "bench")]
-use test::{self, Bencher};
+use test::Bencher;
use std::prelude::v1::*;
@@ -93,7 +93,7 @@
_ => UnicodeWidthChar::width(c),
}
}
-#[cfg(all(feature = "bench", not(feature = "no_std")))]
+#[cfg(feature = "bench")]
#[bench]
fn enwik8(b: &mut Bencher) {
// To benchmark, download & unzip `enwik8` from https://data.deepai.org/enwik8.zip
@@ -101,7 +101,7 @@
let string = std::fs::read_to_string(data_path).unwrap_or_default();
b.iter(|| test::black_box(UnicodeWidthStr::width(string.as_str())));
}
-#[cfg(all(feature = "bench", not(feature = "no_std")))]
+#[cfg(feature = "bench")]
#[bench]
fn jawiki(b: &mut Bencher) {
// To benchmark, download & extract `jawiki-20220501-pages-articles-multistream-index.txt` from
@@ -140,8 +140,6 @@
#[test]
fn test_char() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('h'), Some(2));
assert_eq!('h'.width_cjk(), Some(2));
@@ -156,8 +154,6 @@
#[test]
fn test_char2() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\x00'), Some(0));
assert_eq!('\x00'.width_cjk(), Some(0));
@@ -187,8 +183,6 @@
#[test]
fn unicode_12() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\u{1F971}'), Some(2));
}
@@ -196,8 +190,6 @@
#[test]
fn test_default_ignorable() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\u{E0000}'), Some(0));
@@ -209,8 +201,6 @@
#[test]
fn test_jamo() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\u{1100}'), Some(2));
assert_eq!(UnicodeWidthChar::width('\u{A97C}'), Some(2));
@@ -225,8 +215,6 @@
#[test]
fn test_prepended_concatenation_marks() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\u{0600}'), Some(1));
assert_eq!(UnicodeWidthChar::width('\u{070F}'), Some(1));
@@ -237,8 +225,6 @@
#[test]
fn test_interlinear_annotation_chars() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\u{FFF9}'), Some(1));
assert_eq!(UnicodeWidthChar::width('\u{FFFA}'), Some(1));
@@ -248,8 +234,6 @@
#[test]
fn test_hieroglyph_format_controls() {
use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{None, Some};
assert_eq!(UnicodeWidthChar::width('\u{13430}'), Some(1));
assert_eq!(UnicodeWidthChar::width('\u{13436}'), Some(1));