Skip to content

Commit 6ca24f3

Browse files
committed
support meta
1 parent d3bb95b commit 6ca24f3

File tree

8 files changed

+201
-164
lines changed

8 files changed

+201
-164
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lazy-static-include"
3-
version = "2.2.2"
3+
version = "2.2.3"
44
authors = ["Magic Len <len@magiclen.org>"]
55
edition = "2018"
66
repository = "https://github.com/magiclen/lazy-static-include"

benches/bench.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#[macro_use]
22
extern crate bencher;
33

4-
#[macro_use]
5-
extern crate lazy_static;
6-
74
#[macro_use]
85
extern crate lazy_static_include;
96

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ cargo bench
136136
```
137137
*/
138138

139+
extern crate lazy_static;
140+
139141
#[doc(hidden)]
140142
pub extern crate syn;
141143

@@ -146,3 +148,5 @@ mod macro_include_array;
146148
mod macro_include_bytes;
147149
mod macro_include_counter;
148150
mod macro_include_str;
151+
152+
pub use lazy_static::lazy_static;

src/macro_include_array.rs

Lines changed: 89 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -490,82 +490,82 @@ macro_rules! lazy_static_include_array_inner_f {
490490
macro_rules! lazy_static_include_array_inner {
491491
( $name:ident: [isize; $s:expr], $path:expr ) => {
492492
{
493-
lazy_static_include_array_inner_i!($name: [isize; $s], $path)
493+
$crate::lazy_static_include_array_inner_i!($name: [isize; $s], $path)
494494
}
495495
};
496496
( $name:ident: [i8; $s:expr], $path:expr ) => {
497497
{
498-
lazy_static_include_array_inner_i!($name: [i8; $s], $path)
498+
$crate::lazy_static_include_array_inner_i!($name: [i8; $s], $path)
499499
}
500500
};
501501
( $name:ident: [i16; $s:expr], $path:expr ) => {
502502
{
503-
lazy_static_include_array_inner_i!($name: [i16; $s], $path)
503+
$crate::lazy_static_include_array_inner_i!($name: [i16; $s], $path)
504504
}
505505
};
506506
( $name:ident: [i32; $s:expr], $path:expr ) => {
507507
{
508-
lazy_static_include_array_inner_i!($name: [i32; $s], $path)
508+
$crate::lazy_static_include_array_inner_i!($name: [i32; $s], $path)
509509
}
510510
};
511511
( $name:ident: [i64; $s:expr], $path:expr ) => {
512512
{
513-
lazy_static_include_array_inner_i!($name: [i64; $s], $path)
513+
$crate::lazy_static_include_array_inner_i!($name: [i64; $s], $path)
514514
}
515515
};
516516
( $name:ident: [i128; $s:expr], $path:expr ) => {
517517
{
518-
lazy_static_include_array_inner_i!($name: [i128; $s], $path)
518+
$crate::lazy_static_include_array_inner_i!($name: [i128; $s], $path)
519519
}
520520
};
521521
( $name:ident: [f32; $s:expr], $path:expr ) => {
522522
{
523-
lazy_static_include_array_inner_f!($name: [f32; $s], $path)
523+
$crate::lazy_static_include_array_inner_f!($name: [f32; $s], $path)
524524
}
525525
};
526526
( $name:ident: [f64; $s:expr], $path:expr ) => {
527527
{
528-
lazy_static_include_array_inner_f!($name: [f64; $s], $path)
528+
$crate::lazy_static_include_array_inner_f!($name: [f64; $s], $path)
529529
}
530530
};
531531
( $name:ident: [usize; $s:expr], $path:expr ) => {
532532
{
533-
lazy_static_include_array_inner_u!($name: [usize; $s], $path)
533+
$crate::lazy_static_include_array_inner_u!($name: [usize; $s], $path)
534534
}
535535
};
536536
( $name:ident: [u8; $s:expr], $path:expr ) => {
537537
{
538-
lazy_static_include_array_inner_u!($name: [u8; $s], $path)
538+
$crate::lazy_static_include_array_inner_u!($name: [u8; $s], $path)
539539
}
540540
};
541541
( $name:ident: [u16; $s:expr], $path:expr ) => {
542542
{
543-
lazy_static_include_array_inner_u!($name: [u16; $s], $path)
543+
$crate::lazy_static_include_array_inner_u!($name: [u16; $s], $path)
544544
}
545545
};
546546
( $name:ident: [u32; $s:expr], $path:expr ) => {
547547
{
548-
lazy_static_include_array_inner_u!($name: [u32; $s], $path)
548+
$crate::lazy_static_include_array_inner_u!($name: [u32; $s], $path)
549549
}
550550
};
551551
( $name:ident: [u64; $s:expr], $path:expr ) => {
552552
{
553-
lazy_static_include_array_inner_u!($name: [u64; $s], $path)
553+
$crate::lazy_static_include_array_inner_u!($name: [u64; $s], $path)
554554
}
555555
};
556556
( $name:ident: [u128; $s:expr], $path:expr ) => {
557557
{
558-
lazy_static_include_array_inner_u!($name: [u128; $s], $path)
558+
$crate::lazy_static_include_array_inner_u!($name: [u128; $s], $path)
559559
}
560560
};
561561
( $name:ident: [char; $s:expr], $path:expr ) => {
562562
{
563-
lazy_static_include_array_inner_c!($name: [char; $s], $path)
563+
$crate::lazy_static_include_array_inner_c!($name: [char; $s], $path)
564564
}
565565
};
566566
( $name:ident: [bool; $s:expr], $path:expr ) => {
567567
{
568-
lazy_static_include_array_inner_b!($name: [bool; $s], $path)
568+
$crate::lazy_static_include_array_inner_b!($name: [bool; $s], $path)
569569
}
570570
};
571571
( $name:ident: [&'static str; $s:expr], Vec, $($paths:expr), + ) => {
@@ -581,7 +581,7 @@ macro_rules! lazy_static_include_array_inner {
581581
};
582582
( $name:ident: [&'static str; $s:expr], $path:expr ) => {
583583
{
584-
lazy_static_include_array_inner_s!($name: [&'static str; $s], $path)
584+
$crate::lazy_static_include_array_inner_s!($name: [&'static str; $s], $path)
585585
}
586586
};
587587
( $name:ident: [$t:ident; $s:expr], Vec, $($paths:expr), + ) => {
@@ -625,98 +625,116 @@ macro_rules! lazy_static_include_array_inner {
625625

626626
#[macro_export]
627627
macro_rules! lazy_static_include_array {
628-
( $name:ident: [&'static str; $s:expr], $path:expr $(,)* ) => {
629-
lazy_static! {
630-
static ref $name: [&'static str; $s] = lazy_static_include_array_inner!($name: [&'static str; $s], $path);
628+
( $(#[$attr: meta])* $name:ident: [&'static str; $s:expr], $path:expr $(,)* ) => {
629+
$crate::lazy_static! {
630+
$(#[$attr])*
631+
static ref $name: [&'static str; $s] = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], $path);
631632
}
632633
};
633-
( $name:ident: [&'static str; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
634-
lazy_static! {
635-
static ref $name: Vec<[&'static str; $s]> = lazy_static_include_array_inner!($name: [&'static str; $s], $path $(, $paths)+);
634+
( $(#[$attr: meta])* $name:ident: [&'static str; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
635+
$crate::lazy_static! {
636+
$(#[$attr])*
637+
static ref $name: Vec<[&'static str; $s]> = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], $path $(, $paths)+);
636638
}
637639
};
638-
( pub $name:ident: [&'static str; $s:expr], $path:expr $(,)* ) => {
639-
lazy_static! {
640-
pub static ref $name: [&'static str; $s] = lazy_static_include_array_inner!($name: [&'static str; $s], $path);
640+
( $(#[$attr: meta])* pub $name:ident: [&'static str; $s:expr], $path:expr $(,)* ) => {
641+
$crate::lazy_static! {
642+
$(#[$attr])*
643+
pub static ref $name: [&'static str; $s] = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], $path);
641644
}
642645
};
643-
( pub($($vis:tt)*) $name:ident: [&'static str; $s:expr], $path:expr $(,)* ) => {
644-
lazy_static! {
645-
pub($($vis)*) static ref $name: [&'static str; $s] = lazy_static_include_array_inner!($name: [&'static str; $s], $path);
646+
( $(#[$attr: meta])* pub($($vis:tt)*) $name:ident: [&'static str; $s:expr], $path:expr $(,)* ) => {
647+
$crate::lazy_static! {
648+
$(#[$attr])*
649+
pub($($vis)*) static ref $name: [&'static str; $s] = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], $path);
646650
}
647651
};
648-
( pub $name:ident: [&'static str; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
649-
lazy_static! {
650-
pub static ref $name: Vec<[&'static str; $s]> = lazy_static_include_array_inner!($name: [&'static str; $s], $path $(, $paths)+);
652+
( $(#[$attr: meta])* pub $name:ident: [&'static str; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
653+
$crate::lazy_static! {
654+
$(#[$attr])*
655+
pub static ref $name: Vec<[&'static str; $s]> = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], $path $(, $paths)+);
651656
}
652657
};
653-
( pub($($vis:tt)*) $name:ident: [&'static str; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
654-
lazy_static! {
655-
pub($($vis)*) static ref $name: Vec<[&'static str; $s]> = lazy_static_include_array_inner!($name: [&'static str; $s], $path $(, $paths)+);
658+
( $(#[$attr: meta])* pub($($vis:tt)*) $name:ident: [&'static str; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
659+
$crate::lazy_static! {
660+
$(#[$attr])*
661+
pub($($vis)*) static ref $name: Vec<[&'static str; $s]> = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], $path $(, $paths)+);
656662
}
657663
};
658-
( $name:ident: [$t:ident; $s:expr], $path:expr $(,)* ) => {
659-
lazy_static! {
660-
static ref $name: [$t; $s] = lazy_static_include_array_inner!($name: [$t; $s], $path);
664+
( $(#[$attr: meta])* $name:ident: [$t:ident; $s:expr], $path:expr $(,)* ) => {
665+
$crate::lazy_static! {
666+
$(#[$attr])*
667+
static ref $name: [$t; $s] = $crate::lazy_static_include_array_inner!($name: [$t; $s], $path);
661668
}
662669
};
663-
( $name:ident: [$t:ident; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
664-
lazy_static! {
665-
static ref $name: Vec<[$t; $s]> = lazy_static_include_array_inner!($name: [$t; $s], $path $(, $paths)+);
670+
( $(#[$attr: meta])* $name:ident: [$t:ident; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
671+
$crate::lazy_static! {
672+
$(#[$attr])*
673+
static ref $name: Vec<[$t; $s]> = $crate::lazy_static_include_array_inner!($name: [$t; $s], $path $(, $paths)+);
666674
}
667675
};
668-
( pub $name:ident: [$t:ident; $s:expr], $path:expr $(,)* ) => {
669-
lazy_static! {
670-
pub static ref $name: [$t; $s] = lazy_static_include_array_inner!($name: [$t; $s], $path);
676+
( $(#[$attr: meta])* pub $name:ident: [$t:ident; $s:expr], $path:expr $(,)* ) => {
677+
$crate::lazy_static! {
678+
$(#[$attr])*
679+
pub static ref $name: [$t; $s] = $crate::lazy_static_include_array_inner!($name: [$t; $s], $path);
671680
}
672681
};
673-
( pub($($vis:tt)*) $name:ident: [$t:ident; $s:expr], $path:expr $(,)* ) => {
674-
lazy_static! {
675-
pub($($vis)*) static ref $name: [$t; $s] = lazy_static_include_array_inner!($name: [$t; $s], $path);
682+
( $(#[$attr: meta])* pub($($vis:tt)*) $name:ident: [$t:ident; $s:expr], $path:expr $(,)* ) => {
683+
$crate::lazy_static! {
684+
$(#[$attr])*
685+
pub($($vis)*) static ref $name: [$t; $s] = $crate::lazy_static_include_array_inner!($name: [$t; $s], $path);
676686
}
677687
};
678-
( pub $name:ident: [$t:ident; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
679-
lazy_static! {
680-
pub static ref $name: Vec<[$t; $s]> = lazy_static_include_array_inner!($name: [$t; $s], $path $(, $paths)+);
688+
( $(#[$attr: meta])* pub $name:ident: [$t:ident; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
689+
$crate::lazy_static! {
690+
$(#[$attr])*
691+
pub static ref $name: Vec<[$t; $s]> = $crate::lazy_static_include_array_inner!($name: [$t; $s], $path $(, $paths)+);
681692
}
682693
};
683-
( pub($($vis:tt)*) $name:ident: [$t:ident; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
684-
lazy_static! {
685-
pub($($vis)*) static ref $name: Vec<[$t; $s]> = lazy_static_include_array_inner!($name: [$t; $s], $path $(, $paths)+);
694+
( $(#[$attr: meta])* pub($($vis:tt)*) $name:ident: [$t:ident; $s:expr], $path:expr, $($paths:expr), + $(,)* ) => {
695+
$crate::lazy_static! {
696+
$(#[$attr])*
697+
pub($($vis)*) static ref $name: Vec<[$t; $s]> = $crate::lazy_static_include_array_inner!($name: [$t; $s], $path $(, $paths)+);
686698
}
687699
};
688700
}
689701

690702
#[macro_export]
691703
macro_rules! lazy_static_include_array_vec {
692-
( $name:ident: [&'static str; $s:expr] $(, $paths:expr)+ $(,)* ) => {
693-
lazy_static! {
694-
static ref $name: Vec<[&'static str; $s]> = lazy_static_include_array_inner!($name: [&'static str; $s], Vec $(, $paths)+);
704+
( $(#[$attr: meta])* $name:ident: [&'static str; $s:expr] $(, $paths:expr)+ $(,)* ) => {
705+
$crate::lazy_static! {
706+
$(#[$attr])*
707+
static ref $name: Vec<[&'static str; $s]> = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], Vec $(, $paths)+);
695708
}
696709
};
697-
( pub $name:ident: [&'static str; $s:expr], $($paths:expr), + $(,)* ) => {
698-
lazy_static! {
699-
pub static ref $name: Vec<[&'static str; $s]> = lazy_static_include_array_inner!($name: [&'static str; $s], Vec $(, $paths)+);
710+
( $(#[$attr: meta])* pub $name:ident: [&'static str; $s:expr], $($paths:expr), + $(,)* ) => {
711+
$crate::lazy_static! {
712+
$(#[$attr])*
713+
pub static ref $name: Vec<[&'static str; $s]> = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], Vec $(, $paths)+);
700714
}
701715
};
702-
( pub($($vis:tt)*) $name:ident: [&'static str; $s:expr], $($paths:expr), + $(,)* ) => {
703-
lazy_static! {
704-
pub($($vis)*) static ref $name: Vec<[&'static str; $s]> = lazy_static_include_array_inner!($name: [&'static str; $s], Vec $(, $paths)+);
716+
( $(#[$attr: meta])* pub($($vis:tt)*) $name:ident: [&'static str; $s:expr], $($paths:expr), + $(,)* ) => {
717+
$crate::lazy_static! {
718+
$(#[$attr])*
719+
pub($($vis)*) static ref $name: Vec<[&'static str; $s]> = $crate::lazy_static_include_array_inner!($name: [&'static str; $s], Vec $(, $paths)+);
705720
}
706721
};
707-
( $name:ident: [$t:ident; $s:expr], $($paths:expr), + $(,)* ) => {
708-
lazy_static! {
709-
static ref $name: Vec<[$t; $s]> = lazy_static_include_array_inner!($name: [$t; $s], Vec $(, $paths)+);
722+
( $(#[$attr: meta])* $name:ident: [$t:ident; $s:expr], $($paths:expr), + $(,)* ) => {
723+
$crate::lazy_static! {
724+
$(#[$attr])*
725+
static ref $name: Vec<[$t; $s]> = $crate::lazy_static_include_array_inner!($name: [$t; $s], Vec $(, $paths)+);
710726
}
711727
};
712-
( pub $name:ident: [$t:ident; $s:expr], $($paths:expr), + $(,)* ) => {
713-
lazy_static! {
714-
pub static ref $name: Vec<[$t; $s]> = lazy_static_include_array_inner!($name: [$t; $s], Vec $(, $paths)+);
728+
( $(#[$attr: meta])* pub $name:ident: [$t:ident; $s:expr], $($paths:expr), + $(,)* ) => {
729+
$crate::lazy_static! {
730+
$(#[$attr])*
731+
pub static ref $name: Vec<[$t; $s]> = $crate::lazy_static_include_array_inner!($name: [$t; $s], Vec $(, $paths)+);
715732
}
716733
};
717-
( pub($($vis:tt)*) $name:ident: [$t:ident; $s:expr], $($paths:expr), + $(,)* ) => {
718-
lazy_static! {
719-
pub($($vis)*) static ref $name: Vec<[$t; $s]> = lazy_static_include_array_inner!($name: [$t; $s], Vec $(, $paths)+);
734+
( $(#[$attr: meta])* pub($($vis:tt)*) $name:ident: [$t:ident; $s:expr], $($paths:expr), + $(,)* ) => {
735+
$crate::lazy_static! {
736+
$(#[$attr])*
737+
pub($($vis)*) static ref $name: Vec<[$t; $s]> = $crate::lazy_static_include_array_inner!($name: [$t; $s], Vec $(, $paths)+);
720738
}
721739
};
722740
}

0 commit comments

Comments
 (0)