Skip to content

Commit bd7c9f7

Browse files
committed
stablize the lazy_static_include_array macro
1 parent f67a46c commit bd7c9f7

File tree

7 files changed

+652
-383
lines changed

7 files changed

+652
-383
lines changed

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lazy-static-include"
3-
version = "1.3.1"
3+
version = "2.0.0"
44
authors = ["Magic Len <len@magiclen.org>"]
55
repository = "https://github.com/magiclen/lazy-static-include"
66
homepage = "https://magiclen.org/lazy-static-include"
@@ -15,11 +15,17 @@ travis-ci = { repository = "magiclen/lazy-static-include", branch = "master" }
1515
appveyor = { repository = "magiclen/lazy-static-include", branch = "master", service = "github" }
1616

1717
[dependencies]
18-
lazy_static = "1.1"
18+
lazy_static = "1.3"
19+
syn = {version = "0.15.31", features = ["parsing", "full"], optional = true}
20+
starts-ends-with-caseless = {version = "0.2.1", optional = true}
1921

2022
[dev-dependencies]
2123
criterion = "0.2.5"
22-
serde_json = "1.0.33"
24+
serde_json = "1.0"
25+
26+
[features]
27+
default = ["starts-ends-with-caseless", "syn"]
28+
no_std = []
2329

2430
[[bench]]
2531
name = "bench"

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ lazy_static_include_str!(TEST, "data/test.txt", "data/test-2.txt");
6565
let v: &Vec<&'static str> = &*TEST;
6666
```
6767

68-
## Include Array (temporarily deprecated)
68+
## Include Array
6969

7070
There is a special macro `lazy_static_include_array` which can include arrays from files.
71-
The array is fixed sized and can be one of these following types: `bool`, `char`, `u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`, `f32`, `f64`, `&'static str`.
71+
The array is fixed sized and can be one of these following types: `bool`, `char`, `usize`, `u8`, `u16`, `u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`, `f32`, `f64`, `&'static str`.
7272

7373
Also, the `lazy_static_include_array` macro includes data from files into the compiled executable binary file **only** when you are using the **release** profile.
7474
Be careful when you distribute your program.
@@ -114,6 +114,19 @@ assert_eq!("Hello", TEST[1]);
114114
assert_eq!("哈囉", TEST[2]);
115115
```
116116

117+
## No Std
118+
119+
This crate can work without std, but the `lazy_static_include_array` macro will be disabled unless using the **release** profile.
120+
121+
Enable the feature **no_std** to compile this crate without std.
122+
123+
```toml
124+
[dependencies.lazy-static-include]
125+
version = "*"
126+
features = ["no_std"]
127+
default-features = false
128+
```
129+
117130
## Benchmark
118131

119132
Using static mechanisms makes your program faster. See my benchmark result below (Intel i7-6700HQ, ran on 2018/11/14):

data/isize_array.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[123, -456, 789, 1_000, 5000isize]

data/usize_array.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[123, 456, 789, 1_000, 5000usize]

src/lib.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ lazy_static_include_str!(TEST, "data/test.txt", "data/test-2.txt");
6262
let v: &Vec<&'static str> = &*TEST;
6363
```
6464
65-
## Include Array (temporarily deprecated)
65+
## Include Array
6666
6767
There is a special macro `lazy_static_include_array` which can include arrays from files.
68-
The array is fixed sized and can be one of these following types: `bool`, `char`, `u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`, `f32`, `f64`, `&'static str`.
68+
The array is fixed sized and can be one of these following types: `bool`, `char`, `usize`, `u8`, `u16`, `u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`, `f32`, `f64`, `&'static str`.
6969
7070
Also, the `lazy_static_include_array` macro includes data from files into the compiled executable binary file **only** when you are using the **release** profile.
7171
Be careful when you distribute your program.
7272
73-
```rust
73+
```rust,ignore
7474
#[macro_use] extern crate lazy_static_include;
7575
#[macro_use] extern crate lazy_static;
7676
@@ -82,7 +82,7 @@ assert_eq!(1000, TEST[3]);
8282
assert_eq!(500000000000u64, TEST[4]);
8383
```
8484
85-
```rust
85+
```rust,ignore
8686
#[macro_use] extern crate lazy_static_include;
8787
#[macro_use] extern crate lazy_static;
8888
@@ -100,7 +100,7 @@ assert_eq!(-4, TEST[1][3]);
100100
assert_eq!(-5, TEST[1][4]);
101101
```
102102
103-
```rust
103+
```rust,ignore
104104
#[macro_use] extern crate lazy_static_include;
105105
#[macro_use] extern crate lazy_static;
106106
@@ -111,6 +111,19 @@ assert_eq!("Hello", TEST[1]);
111111
assert_eq!("哈囉", TEST[2]);
112112
```
113113
114+
## No Std
115+
116+
This crate can work without std, but the `lazy_static_include_array` macro will be disabled unless using the **release** profile.
117+
118+
Enable the feature **no_std** to compile this crate without std.
119+
120+
```toml
121+
[dependencies.lazy-static-include]
122+
version = "*"
123+
features = ["no_std"]
124+
default-features = false
125+
```
126+
114127
## Benchmark
115128
116129
Using static mechanisms makes your program faster. See my benchmark result below (Intel i7-6700HQ, ran on 2018/11/14):
@@ -146,7 +159,16 @@ You can run the benchmark program by executing,
146159
cargo bench
147160
```
148161
*/
149-
#![no_std]
162+
163+
#![cfg_attr(feature = "no_std", no_std)]
164+
165+
#[cfg(all(debug_assertions, not(feature = "no_std")))]
166+
#[doc(hidden)]
167+
pub extern crate syn;
168+
169+
#[cfg(all(debug_assertions, not(feature = "no_std")))]
170+
#[doc(hidden)]
171+
pub extern crate starts_ends_with_caseless;
150172

151173
mod macro_include_counter;
152174
mod macro_include_str;

0 commit comments

Comments
 (0)