Skip to content

Commit 11f6aaf

Browse files
committed
Allow macros to be imported with use instead of #[macro_use]
1 parent 45bc47e commit 11f6aaf

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/macros.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ use std::mem::MaybeUninit;
1212
/// # Example
1313
///
1414
/// ```rust
15-
/// #[macro_use] extern crate cssparser;
16-
///
1715
/// # fn main() {} // Make doctest not wrap everything in its own main
1816
/// # fn dummy(function_name: &String) { let _ =
19-
/// match_ignore_ascii_case! { &function_name,
17+
/// cssparser::match_ignore_ascii_case! { &function_name,
2018
/// "rgb" => parse_rgb(..),
2119
/// # #[cfg(not(something))]
2220
/// "rgba" => parse_rgba(..),
@@ -51,7 +49,7 @@ macro_rules! match_ignore_ascii_case {
5149
$( $( $pattern )+ )+
5250
}
5351
}
54-
_cssparser_internal_to_lowercase!($input, cssparser_internal::MAX_LENGTH => lowercase);
52+
$crate::_cssparser_internal_to_lowercase!($input, cssparser_internal::MAX_LENGTH => lowercase);
5553
// "A" is a short string that we know is different for every string pattern,
5654
// since we’ve verified that none of them include ASCII upper case letters.
5755
match lowercase.unwrap_or("A") {
@@ -74,12 +72,10 @@ macro_rules! match_ignore_ascii_case {
7472
/// ## Example:
7573
///
7674
/// ```rust
77-
/// #[macro_use] extern crate cssparser;
78-
///
7975
/// # fn main() {} // Make doctest not wrap everything in its own main
8076
///
8177
/// fn color_rgb(input: &str) -> Option<(u8, u8, u8)> {
82-
/// ascii_case_insensitive_phf_map! {
78+
/// cssparser::ascii_case_insensitive_phf_map! {
8379
/// keyword -> (u8, u8, u8) = {
8480
/// "red" => (255, 0, 0),
8581
/// "green" => (0, 255, 0),
@@ -108,7 +104,7 @@ macro_rules! ascii_case_insensitive_phf_map {
108104
$key => $value,
109105
)*
110106
};
111-
_cssparser_internal_to_lowercase!(input, _cssparser_internal::MAX_LENGTH => lowercase);
107+
$crate::_cssparser_internal_to_lowercase!(input, _cssparser_internal::MAX_LENGTH => lowercase);
112108
lowercase.and_then(|s| MAP.get(s))
113109
}
114110
}

src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ fn utf16_columns() {
14871487
#[test]
14881488
fn servo_define_css_keyword_enum() {
14891489
macro_rules! define_css_keyword_enum {
1490-
(pub enum $name:ident { $($variant:ident = $css:expr,)+ }) => {
1490+
(pub enum $name:ident { $($variant:ident = $css:pat,)+ }) => {
14911491
#[derive(PartialEq, Debug)]
14921492
pub enum $name {
14931493
$($variant),+

0 commit comments

Comments
 (0)