Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no_std + checking no_std builds in Travis CI #15

Merged
merged 2 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ rust:
- nightly
- beta
- stable

script:
- cargo test
- if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
cargo build --no-default-features;
fi
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ license = "MIT"
description = "The arena, a fast but limited type of allocator"
documentation = "https://docs.rs/typed-arena"
repository = "https://github.com/SimonSapin/rust-typed-arena"
categories = ["memory-management"]
categories = ["memory-management", "no-std"]

[lib]
name = "typed_arena"
path = "src/lib.rs"
doctest = false

[features]
default = ["std"]
std = []
24 changes: 18 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@
// 2) add and stabilize placement new.
// 3) use an iterator. This may add far too much unsafe code.

use std::cell::RefCell;
use std::cmp;
use std::iter;
use std::mem;
use std::slice;
#![cfg_attr(not(any(feature = "std", test)), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]

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

#[cfg(any(feature = "std", test))]
extern crate core;

#[cfg(not(feature = "std"))]
use alloc::Vec;

use core::cell::RefCell;
use core::cmp;
use core::iter;
use core::mem;
use core::slice;

#[cfg(test)]
mod test;
Expand Down Expand Up @@ -51,7 +63,7 @@ impl<T> Arena<T> {
Arena {
chunks: RefCell::new(ChunkList {
current: Vec::with_capacity(n),
rest: vec![],
rest: Vec::new(),
}),
}
}
Expand Down