Skip to content

Commit

Permalink
feature: add 'std' feature, deprecate 'use_std'
Browse files Browse the repository at this point in the history
We'll remove 'use_std' in regex 2, but keep it around for backward
compatibility.

Fixes #474
  • Loading branch information
BurntSushi committed Sep 3, 2019
1 parent 29f39b8 commit da1f5b6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
UNRELEASED
==========

New features:

* [FEATURE #474](https://github.com/rust-lang/regex/issues/474):
The `use_std` feature has been deprecated in favor of the `std` feature.
The `use_std` feature will be removed in regex 2. Until then, `use_std` will
remain as an alias for the `std` feature.


1.2.1 (2019-08-03)
==================
This release does a bit of house cleaning. Namely:
Expand Down
19 changes: 12 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,22 @@ rand = "0.6.5"
doc-comment = "0.3"

[features]
default = ["use_std"]
# The 'use_std' feature permits the regex crate to use the standard library.
# This is intended to support future use cases where the regex crate may be
# able to compile without std, and instead just rely on 'core' and 'alloc'
# (for example). Currently, this isn't supported, and removing the 'use_std'
# feature will prevent regex from compiling.
use_std = []
default = ["std"]
# The 'std' feature permits the regex crate to use the standard library. This
# is intended to support future use cases where the regex crate may be able
# to compile without std, and instead just rely on 'core' and 'alloc' (for
# example). Currently, this isn't supported, and removing the 'std' feature
# will prevent regex from compiling.
std = []
# The 'use_std' feature is DEPRECATED. It will be removed in regex 2. Until
# then, it is alias for the 'std' feature.
use_std = ["std"]

# A blanket feature that governs whether unstable features are enabled or not.
# Unstable features are disabled by default, and typically rely on unstable
# features in rustc itself.
unstable = ["pattern"]

# Enable to use the unstable pattern traits defined in std. This is enabled
# by default if the unstable feature is enabled.
pattern = []
Expand Down
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ used by adding `regex` to your dependencies in your project's `Cargo.toml`.
regex = "1"
```
and this to your crate root:
If you're using Rust 2015, then you'll also need to add it to your crate root:
```rust
extern crate regex;
Expand Down Expand Up @@ -511,8 +511,8 @@ another matching engine with fixed memory requirements.
#![cfg_attr(test, deny(warnings))]
#![cfg_attr(feature = "pattern", feature(pattern))]

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

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

#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
pub use error::Error;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
pub use re_builder::set_unicode::*;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
pub use re_builder::unicode::*;
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
pub use re_set::unicode::*;
#[cfg(feature = "use_std")]
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
#[cfg(feature = "std")]
pub use re_unicode::{
escape, CaptureLocations, CaptureMatches, CaptureNames, Captures,
Locations, Match, Matches, NoExpand, Regex, Replacer, ReplacerRef, Split,
Expand Down Expand Up @@ -630,7 +630,7 @@ When the `s` flag is enabled, `.` matches any byte.
In general, one should expect performance on `&[u8]` to be roughly similar to
performance on `&str`.
*/
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
pub mod bytes {
pub use re_builder::bytes::*;
pub use re_builder::set_bytes::*;
Expand Down Expand Up @@ -663,7 +663,7 @@ mod utf8;
/// testing different matching engines and supporting the `regex-debug` CLI
/// utility.
#[doc(hidden)]
#[cfg(feature = "use_std")]
#[cfg(feature = "std")]
pub mod internal {
pub use compile::Compiler;
pub use exec::{Exec, ExecBuilder};
Expand Down

0 comments on commit da1f5b6

Please sign in to comment.