Skip to content

Commit d42a518

Browse files
committed
make import of other crates not necessary anymore, use once_cell
Fix #1
1 parent 3d1b179 commit d42a518

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<a name="v1.1.0"></a>
2+
### v1.1.0 - 2021-05-08
3+
- no more complementary import needed
4+
- now based on once_cell instead of lazy_static
5+
6+
<a name="v1.0.0"></a>
7+
### v1.0.0 - 2021-05-04
8+
- first public release

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
[package]
22
name = "lazy-regex"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
authors = ["Canop <[email protected]>"]
55
edition = "2018"
66
description = "a macro to reduce regex creation boilerplate"
7-
keywords = ["macro", "lazy_static", "regex"]
7+
keywords = ["macro", "lazy", "static", "regex"]
88
license = "MIT"
99
categories = ["text-processing"]
1010
repository = "https://github.com/Canop/lazy-regex"
1111
readme = "README.md"
1212

1313
[dependencies]
14-
lazy_static = "1"
14+
once_cell = "1.7"
15+
regex = "1.4"
1516

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ The first code comes from the regex documentation.
3333

3434
### Is it really useful ?
3535

36-
Regarding the binary, it's *exactly* as using lazy_static. It just makes some code a little easier to read. You're judge.
36+
Regarding the binary, it's as using lazy_static or once_cell.
37+
It just makes some code a little easier to read. You're judge.
3738

3839
### Can I have several `regex!` in the same function ? On the same Line ?
3940

@@ -49,4 +50,4 @@ You mean something like `regex!("somestring", "i")` ? Cool. I was just waiting f
4950

5051
### What's the licence ?
5152

52-
It's MIT. But you're also free to just copy the macro in your code if it's simpler, no attribution is needed.
53+
It's MIT. No attribution is needed.

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ fn some_helper_function(text: &str) -> bool {
2626
2727
*/
2828

29+
pub use once_cell;
30+
2931
#[macro_export]
3032
macro_rules! regex {
3133
($s: literal) => {{
32-
use regex::Regex;
33-
lazy_static! {
34-
static ref RE: Regex = Regex::new($s).unwrap();
35-
}
36-
&*RE
34+
use lazy_regex::once_cell::sync::OnceCell;
35+
static RE: OnceCell::<regex::Regex> = OnceCell::new();
36+
RE.get_or_init(|| regex::Regex::new($s).unwrap())
3737
}};
3838
}

0 commit comments

Comments
 (0)