8000 Make no_std unconditional; remove optional feature · cmyr/unicode-segmentation@092239b · GitHub
[go: up one dir, main page]

Skip to content

Commit 092239b

Browse files
committed
Make no_std unconditional; remove optional feature
All of the libcore functionality used in this crate is now stable, so it is no longer necessary to disable it when using stable Rust versions.
1 parent 72979a1 commit 092239b

File tree

9 files changed

+14
-60
lines changed

9 files changed

+14
-60
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ language: rust
22
rust: 'nightly'
33
sudo: false
44
script:
5-
- cargo build --verbose --features no_std
6-
- cargo test --verbose --features no_std
7-
- cargo clean
8-
- cargo build --verbose --features default
9-
- cargo test --verbose --features default
5+
- cargo build --verbose
6+
- cargo test --verbose
107
- rustdoc --test README.md -L target/debug -L target/debug/deps
118
- cargo doc
129
after_success: |

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "unicode-segmentation"
4-
version = "0.1.2"
4+
version = "0.1.3"
55
authors = ["kwantam <kwantam@gmail.com>"]
66

77
homepage = "https://github.com/unicode-rs/unicode-segmentation"
@@ -19,5 +19,4 @@ according to Unicode Standard Annex #29 rules.
1919
exclude = [ "target/*", "Cargo.lock", "scripts/tmp" ]
2020

2121
[features]
22-
default = []
23-
no_std = []
22+
no_std = [] # This is a no-op, preserved for backward compatibility only.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ fn main() {
2828
}
2929
```
3030

31-
# features
31+
# no_std
3232

33-
unicode-segmentation supports a `no_std` feature. This eliminates dependence on std,
34-
and instead uses equivalent functions from core.
33+
unicode-segmentation does not depend on libstd, so it can be used in crates
34+
with the `#![no_std]` attribute.
3535

3636
# crates.io
3737

scripts/unicode.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,7 @@ def emit_util_mod(f):
210210
pub mod util {
211211
#[inline]
212212
pub fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
213-
#[cfg(feature = "no_std")]
214213
use core::cmp::Ordering::{Equal, Less, Greater};
215-
#[cfg(feature = "no_std")]
216-
use core::slice::SliceExt;
217-
218-
#[cfg(not(feature = "no_std"))]
219-
use std::cmp::Ordering::{Equal, Less, Greater};
220214
r.binary_search_by(|&(lo,hi)| {
221215
if lo <= c && c <= hi { Equal }
222216
else if hi < c { Less }
@@ -263,9 +257,7 @@ def emit_property_module(f, mod, tbl, emit):
263257
def emit_break_module(f, break_table, break_cats, name):
264258
Name = name.capitalize()
265259
f.write("""pub mod %s {
266-
#[cfg(feature = "no_std")]
267260
use core::slice::SliceExt;
268-
#[cfg(feature = "no_std")]
269261
use core::result::Result::{Ok, Err};
270262
271263
pub use self::%sCat::*;
@@ -282,10 +274,7 @@ def emit_break_module(f, break_table, break_cats, name):
282274
f.write(""" }
283275
284276
fn bsearch_range_value_table(c: char, r: &'static [(char, char, %sCat)]) -> %sCat {
285-
#[cfg(feature = "no_std")]
286277
use core::cmp::Ordering::{Equal, Less, Greater};
287-
#[cfg(not(feature = "no_std"))]
288-
use std::cmp::Ordering::{Equal, Less, Greater};
289278
match r.binary_search_by(|&(lo, hi, _)| {
290279
if lo <= c && c <= hi { Equal }
291280
else if hi < c { Less }

src/grapheme.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[cfg(feature = "no_std")]
1211
use core::cmp;
1312

14-
#[cfg(not(feature = "no_std"))]
15-
use std::cmp;
16-
1713
use tables::grapheme::GraphemeCat;
1814

1915
/// External iterator for grapheme clusters and byte offsets.

src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434
//! }
3535
//! ```
3636
//!
37+
//! # no_std
38+
//!
39+
//! unicode-segmentation does not depend on libstd, so it can be used in crates
40+
//! with the `#![no_std]` attribute.
41+
//!
3742
//! # crates.io
3843
//!
3944
//! You can use this package in your project by adding the following
4045
//! to your `Cargo.toml`:
4146
//!
42-
//! # features
43-
//!
44-
//! unicode-segmentation supports a `no_std` feature. This eliminates dependence on std,
45-
//! and instead uses equivalent functions from core.
46-
//!
4747
//! ```toml
4848
//! [dependencies]
4949
//! unicode-segmentation = "0.1.0"
@@ -53,10 +53,9 @@
5353
#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png",
5454
html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")]
5555

56-
#![cfg_attr(feature = "no_std", no_std)]
57-
#![cfg_attr(feature = "no_std", feature(no_std, core_char_ext, core_slice_ext, core_str_ext))]
56+
#![no_std]
5857

59-
#[cfg(all(test, feature = "no_std"))]
58+
#[cfg(test)]
6059
#[macro_use]
6160
extern crate std;
6261

src/tables.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ pub const UNICODE_VERSION: (u64, u64, u64) = (8, 0, 0);
1919
pub mod util {
2020
#[inline]
2121
pub fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
22-
#[cfg(feature = "no_std")]
2322
use core::cmp::Ordering::{Equal, Less, Greater};
24-
#[cfg(feature = "no_std")]
25-
use core::slice::SliceExt;
26-
27-
#[cfg(not(feature = "no_std"))]
28-
use std::cmp::Ordering::{Equal, Less, Greater};
2923
r.binary_search_by(|&(lo,hi)| {
3024
if lo <= c && c <= hi { Equal }
3125
else if hi < c { Less }
@@ -285,9 +279,6 @@ mod derived_property {
285279
}
286280

287281
pub mod grapheme {
288-
#[cfg(feature = "no_std")]
289-
use core::slice::SliceExt;
290-
#[cfg(feature = "no_std")]
291282
use core::result::Result::{Ok, Err};
292283

293284
pub use self::GraphemeCat::*;
@@ -308,10 +299,7 @@ pub mod grapheme {
308299
}
309300

310301
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
311-
#[cfg(feature = "no_std")]
312302
use core::cmp::Ordering::{Equal, Less, Greater};
313-
#[cfg(not(feature = "no_std"))]
314-
use std::cmp::Ordering::{Equal, Less, Greater};
315303
match r.binary_search_by(|&(lo, hi, _)| {
316304
if lo <= c && c <= hi { Equal }
317305
else if hi < c { Less }
@@ -829,9 +817,6 @@ pub mod grapheme {
829817
}
830818

831819
pub mod word {
832-
#[cfg(feature = "no_std")]
833-
use core::slice::SliceExt;
834-
#[cfg(feature = "no_std")]
835820
use core::result::Result::{Ok, Err};
836821

837822
pub use self::WordCat::*;
@@ -859,10 +844,7 @@ pub mod word {
859844
}
860845

861846
fn bsearch_range_value_table(c: char, r: &'static [(char, char, WordCat)]) -> WordCat {
862-
#[cfg(feature = "no_std")]
863847
use core::cmp::Ordering::{Equal, Less, Greater};
864-
#[cfg(not(feature = "no_std"))]
865-
use std::cmp::Ordering::{Equal, Less, Greater};
866848
match r.binary_search_by(|&(lo, hi, _)| {
867849
if lo <= c && c <= hi { Equal }
868850
else if hi < c { Less }

src/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use super::UnicodeSegmentation;
1212

13-
#[cfg(feature = "no_std")]
1413
use std::prelude::v1::*;
1514

1615
#[test]

src/word.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[cfg(feature = "no_std")]
1211
use core::cmp;
13-
#[cfg(feature = "no_std")]
1412
use core::iter::Filter;
1513

16-
#[cfg(not(feature = "no_std"))]
17-
use std::cmp;
18-
#[cfg(not(feature = "no_std"))]
19-
use std::iter::Filter;
20-
2114
use tables::word::WordCat;
2215

2316
/// An iterator over the substrings of a string which, after splitting the string on

0 commit comments

Comments
 (0)
0