Skip to content

Commit da1f5b6

Browse files
committed
feature: add 'std' feature, deprecate 'use_std'
We'll remove 'use_std' in regex 2, but keep it around for backward compatibility. Fixes #474
1 parent 29f39b8 commit da1f5b6

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
UNRELEASED
2+
==========
3+
4+
New features:
5+
6+
* [FEATURE #474](https://github.com/rust-lang/regex/issues/474):
7+
The `use_std` feature has been deprecated in favor of the `std` feature.
8+
The `use_std` feature will be removed in regex 2. Until then, `use_std` will
9+
remain as an alias for the `std` feature.
10+
11+
112
1.2.1 (2019-08-03)
213
==================
314
This release does a bit of house cleaning. Namely:

Cargo.toml

+12-7
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,22 @@ rand = "0.6.5"
4545
doc-comment = "0.3"
4646

4747
[features]
48-
default = ["use_std"]
49-
# The 'use_std' feature permits the regex crate to use the standard library.
50-
# This is intended to support future use cases where the regex crate may be
51-
# able to compile without std, and instead just rely on 'core' and 'alloc'
52-
# (for example). Currently, this isn't supported, and removing the 'use_std'
53-
# feature will prevent regex from compiling.
54-
use_std = []
48+
default = ["std"]
49+
# The 'std' feature permits the regex crate to use the standard library. This
50+
# is intended to support future use cases where the regex crate may be able
51+
# to compile without std, and instead just rely on 'core' and 'alloc' (for
52+
# example). Currently, this isn't supported, and removing the 'std' feature
53+
# will prevent regex from compiling.
54+
std = []
55+
# The 'use_std' feature is DEPRECATED. It will be removed in regex 2. Until
56+
# then, it is alias for the 'std' feature.
57+
use_std = ["std"]
58+
5559
# A blanket feature that governs whether unstable features are enabled or not.
5660
# Unstable features are disabled by default, and typically rely on unstable
5761
# features in rustc itself.
5862
unstable = ["pattern"]
63+
5964
# Enable to use the unstable pattern traits defined in std. This is enabled
6065
# by default if the unstable feature is enabled.
6166
pattern = []

src/lib.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ used by adding `regex` to your dependencies in your project's `Cargo.toml`.
2222
regex = "1"
2323
```
2424
25-
and this to your crate root:
25+
If you're using Rust 2015, then you'll also need to add it to your crate root:
2626
2727
```rust
2828
extern crate regex;
@@ -511,8 +511,8 @@ another matching engine with fixed memory requirements.
511511
#![cfg_attr(test, deny(warnings))]
512512
#![cfg_attr(feature = "pattern", feature(pattern))]
513513

514-
#[cfg(not(feature = "use_std"))]
515-
compile_error!("`use_std` feature is currently required to build this crate");
514+
#[cfg(not(feature = "std"))]
515+
compile_error!("`std` feature is currently required to build this crate");
516516

517517
extern crate aho_corasick;
518518
extern crate memchr;
@@ -527,16 +527,16 @@ extern crate regex_syntax as syntax;
527527
#[cfg(test)]
528528
doc_comment::doctest!("../README.md");
529529

530-
#[cfg(feature = "use_std")]
530+
#[cfg(feature = "std")]
531531
pub use error::Error;
532-
#[cfg(feature = "use_std")]
532+
#[cfg(feature = "std")]
533533
pub use re_builder::set_unicode::*;
534-
#[cfg(feature = "use_std")]
534+
#[cfg(feature = "std")]
535535
pub use re_builder::unicode::*;
536-
#[cfg(feature = "use_std")]
536+
#[cfg(feature = "std")]
537537
pub use re_set::unicode::*;
538-
#[cfg(feature = "use_std")]
539-
#[cfg(feature = "use_std")]
538+
#[cfg(feature = "std")]
539+
#[cfg(feature = "std")]
540540
pub use re_unicode::{
541541
escape, CaptureLocations, CaptureMatches, CaptureNames, Captures,
542542
Locations, Match, Matches, NoExpand, Regex, Replacer, ReplacerRef, Split,
@@ -630,7 +630,7 @@ When the `s` flag is enabled, `.` matches any byte.
630630
In general, one should expect performance on `&[u8]` to be roughly similar to
631631
performance on `&str`.
632632
*/
633-
#[cfg(feature = "use_std")]
633+
#[cfg(feature = "std")]
634634
pub mod bytes {
635635
pub use re_builder::bytes::*;
636636
pub use re_builder::set_bytes::*;
@@ -663,7 +663,7 @@ mod utf8;
663663
/// testing different matching engines and supporting the `regex-debug` CLI
664664
/// utility.
665665
#[doc(hidden)]
666-
#[cfg(feature = "use_std")]
666+
#[cfg(feature = "std")]
667667
pub mod internal {
668668
pub use compile::Compiler;
669669
pub use exec::{Exec, ExecBuilder};

0 commit comments

Comments
 (0)