Skip to content

Commit

Permalink
Link to libstd by default
Browse files Browse the repository at this point in the history
A core-only setup is still usable via the core feature
  • Loading branch information
sfackler committed Feb 1, 2015
1 parent ca0e9f6 commit 24555b1
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 25 deletions.
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,4 +1,5 @@
language: rust
script:
- (cd phf && cargo test)
- (cd phf && cargo test --features core)
- (cd phf_macros && cargo test --features stats)
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.phf_shared]
path = "../phf_shared"
version = "=0.6.1"
Expand Down
12 changes: 9 additions & 3 deletions phf/src/lib.rs
Expand Up @@ -8,7 +8,11 @@
#![no_std]

#[macro_use]
#[cfg(feature = "core")]
extern crate core;
#[macro_use]
#[cfg(not(feature = "core"))]
extern crate std;
extern crate phf_shared;

pub use phf_shared::PhfHash;
Expand All @@ -26,9 +30,11 @@ pub mod set;
pub mod ordered_map;
pub mod ordered_set;

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

10 changes: 5 additions & 5 deletions phf/src/map.rs
@@ -1,9 +1,9 @@
//! An immutable map constructed at compile time.
use core::prelude::*;
use core::borrow::BorrowFrom;
use core::ops::Index;
use core::slice;
use core::fmt;
use std::prelude::v1::*;
use std::borrow::BorrowFrom;
use std::ops::Index;
use std::slice;
use std::fmt;
use PhfHash;
use phf_shared;

Expand Down
12 changes: 6 additions & 6 deletions phf/src/ordered_map.rs
@@ -1,10 +1,10 @@
//! An order-preserving immutable map constructed at compile time.
use core::prelude::*;
use core::borrow::BorrowFrom;
use core::iter::RandomAccessIterator;
use core::ops::Index;
use core::fmt;
use core::slice;
use std::prelude::v1::*;
use std::borrow::BorrowFrom;
use std::iter::RandomAccessIterator;
use std::ops::Index;
use std::fmt;
use std::slice;

use PhfHash;
use phf_shared;
Expand Down
8 changes: 4 additions & 4 deletions phf/src/ordered_set.rs
@@ -1,8 +1,8 @@
//! An order-preserving immutable set constructed at compile time.
use core::prelude::*;
use core::borrow::BorrowFrom;
use core::iter::RandomAccessIterator;
use core::fmt;
use std::prelude::v1::*;
use std::borrow::BorrowFrom;
use std::iter::RandomAccessIterator;
use std::fmt;
use ordered_map;
use {PhfHash, OrderedMap};

Expand Down
6 changes: 3 additions & 3 deletions phf/src/set.rs
@@ -1,7 +1,7 @@
//! An immutable set constructed at compile time.
use core::prelude::*;
use core::borrow::BorrowFrom;
use core::fmt;
use std::prelude::v1::*;
use std::borrow::BorrowFrom;
use std::fmt;

use PhfHash;
use map;
Expand Down
4 changes: 4 additions & 0 deletions phf_shared/Cargo.toml
Expand Up @@ -10,3 +10,7 @@ repository = "https://github.com/sfackler/rust-phf"
name = "phf_shared"
path = "src/lib.rs"
test = false

[features]

core = []
18 changes: 14 additions & 4 deletions phf_shared/src/lib.rs
@@ -1,10 +1,20 @@
#![feature(core, hash)]
#![feature(hash)]
#![cfg_attr(feature = "core", feature(core))]
#![no_std]

#[cfg(feature = "core")]
extern crate core;
#[cfg(not(feature = "core"))]
extern crate std;

use std::slice::AsSlice;
use std::str::StrExt;
use std::hash::{Writer, Hasher, Hash, SipHasher};

use core::slice::AsSlice;
use core::str::StrExt;
use core::hash::{Writer, Hasher, Hash, SipHasher};
#[cfg(feature = "core")]
mod std {
pub use core::{slice, str, hash};
}

#[inline]
pub fn displace(f1: u32, f2: u32, d1: u32, d2: u32) -> u32 {
Expand Down

0 comments on commit 24555b1

Please sign in to comment.