Skip to content

Commit

Permalink
Reinstantiate no_std cargo feature flag.
Browse files Browse the repository at this point in the history
The feature was removed in d4c189a due to heavy refactoring of libcore
before rust 1.0.
  • Loading branch information
gz committed Sep 29, 2015
1 parent 1f770df commit 7c3f757
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -10,3 +10,5 @@ script:
- (test $TRAVIS_RUST_VERSION != "nightly" || (cd phf_macros && cargo bench))
- (cd phf_codegen && cargo test)
- (cd phf_codegen/test && cargo test)
- (cd phf_shared && cargo build --features core)
- (cd phf && cargo build --features core)
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -24,6 +24,8 @@ PHF data structures can be constucted via either the compiler plugins in the
Compiler plugins are not a stable part of Rust at the moment, so `phf_macros`
can only be used with nightlies.

The `phf/core` feature will compile the `phf` crate with a dependency on libcore instead of libstd, enabling use in environments where libstd will not work.

phf_macros
===========

Expand Down
3 changes: 3 additions & 0 deletions phf/Cargo.toml
Expand Up @@ -12,6 +12,9 @@ name = "phf"
path = "src/lib.rs"
test = false

[features]
core = ["phf_shared/core"]

[dependencies]
debug-builders = "0.1"
phf_shared = { version = "=0.7.5", path = "../phf_shared" }
10 changes: 10 additions & 0 deletions phf/src/lib.rs
Expand Up @@ -5,10 +5,20 @@
//! the documentation of those crates for more details.
#![doc(html_root_url="https://sfackler.github.io/rust-phf/doc/v0.7.5")]
#![warn(missing_docs)]
#![cfg_attr(feature = "core", feature(no_std))]
#![cfg_attr(feature = "core", no_std)]

extern crate debug_builders;
extern crate phf_shared;

#[cfg(feature = "core")]
mod std {
pub use core::{borrow, fmt, iter, option, ops, slice};
pub mod prelude {
pub use core::prelude as v1;
}
}

pub use phf_shared::PhfHash;
#[doc(inline)]
pub use map::Map;
Expand Down
3 changes: 3 additions & 0 deletions phf_shared/Cargo.toml
Expand Up @@ -11,3 +11,6 @@ documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_shared"
name = "phf_shared"
path = "src/lib.rs"
test = false

[features]
core = []
7 changes: 7 additions & 0 deletions phf_shared/src/lib.rs
@@ -1,4 +1,11 @@
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.5")]
#![cfg_attr(feature = "core", feature(no_std, core_slice_ext, core_str_ext))]
#![cfg_attr(feature = "core", no_std)]

#[cfg(feature = "core")]
mod std {
pub use core::{slice, str, hash};
}

use std::hash::{Hasher, Hash, SipHasher};

Expand Down

0 comments on commit 7c3f757

Please sign in to comment.