Add collections/alloc features
This commit is contained in:
parent
52c72ecf9f
commit
3b0668806a
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "core_io"
|
name = "core_io"
|
||||||
version = "0.0.20160708"
|
version = "0.1.20160708"
|
||||||
authors = ["The Rust Project Developers", "Jethro Beekman"]
|
authors = ["The Rust Project Developers", "Jethro Beekman"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = """
|
description = """
|
||||||
|
@ -19,3 +19,7 @@ build = "build.rs"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
rustc_version = "0.1.7"
|
rustc_version = "0.1.7"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
alloc = []
|
||||||
|
collections = ["alloc"]
|
||||||
|
|
10
doc.sh
10
doc.sh
|
@ -1,2 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cargo rustdoc -- --html-in-header <(echo '<style type="text/css">.docblock>*, .collapse-toggle, #toggle-all-docs { display: none; } #core_io-show-docblock+p { display: initial }</style>')
|
cd "$(dirname "$0")"
|
||||||
|
HIDE_DOCBLOCKS='.docblock>*, .collapse-toggle, #toggle-all-docs { display: none; } #core_io-show-docblock+p { display: initial }'
|
||||||
|
FIX_ERRORSTRING='.method a.type[title="core_io::ErrorString"]:before { content: "Error"; }'
|
||||||
|
rm -rf target/doc
|
||||||
|
cargo rustdoc --features collections -- --html-in-header <(echo '<style type="text/css">'"$HIDE_DOCBLOCKS"'</style>')
|
||||||
|
mv target/doc target/doc_collections
|
||||||
|
cargo rustdoc --features alloc -- --html-in-header <(echo '<style type="text/css">'"$HIDE_DOCBLOCKS $FIX_ERROR_STRING"'</style>')
|
||||||
|
mv target/doc target/doc_alloc
|
||||||
|
cargo rustdoc -- --html-in-header <(echo '<style type="text/css">'"$HIDE_DOCBLOCKS $FIX_ERROR_STRING"'</style>')
|
||||||
|
|
31
src/lib.rs
31
src/lib.rs
|
@ -6,10 +6,35 @@
|
||||||
#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,str_char)]
|
#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,str_char)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
#[macro_use]
|
#[cfg_attr(feature="collections",macro_use)]
|
||||||
extern crate collections;
|
#[cfg(feature="collections")] extern crate collections;
|
||||||
extern crate alloc;
|
#[cfg(feature="alloc")] extern crate alloc;
|
||||||
extern crate rustc_unicode;
|
extern crate rustc_unicode;
|
||||||
|
|
||||||
|
#[cfg(not(feature="collections"))]
|
||||||
|
pub type ErrorString = &'static str;
|
||||||
|
|
||||||
|
// Provide Box::new wrapper
|
||||||
|
#[cfg(not(feature="alloc"))]
|
||||||
|
struct FakeBox<T>(core::marker::PhantomData<T>);
|
||||||
|
#[cfg(not(feature="alloc"))]
|
||||||
|
impl<T> FakeBox<T> {
|
||||||
|
fn new(val: T) -> T {
|
||||||
|
val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needed for older compilers, to ignore vec!/format! macros in tests
|
||||||
|
#[cfg(not(feature="collections"))]
|
||||||
|
macro_rules! vec (
|
||||||
|
( $ elem : expr ; $ n : expr ) => { () };
|
||||||
|
( $ ( $ x : expr ) , * ) => { () };
|
||||||
|
( $ ( $ x : expr , ) * ) => { () };
|
||||||
|
);
|
||||||
|
#[cfg(not(feature="collections"))]
|
||||||
|
macro_rules! format {
|
||||||
|
( $ ( $ arg : tt ) * ) => { () };
|
||||||
|
}
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/io.rs"));
|
include!(concat!(env!("OUT_DIR"), "/io.rs"));
|
||||||
pub use io::*;
|
pub use io::*;
|
||||||
|
|
Loading…
Reference in New Issue