Skip to content

Commit 9a857f7

Browse files
authored
Merge pull request #3 from ralexstokes/master
Only import `PyParseError` conditionally to avoid a compiler warning
2 parents 1e03122 + 463a07d commit 9a857f7

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/strings.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,50 @@
11
use nom::anychar;
22

3-
#[cfg(feature="unicode-names")]
3+
#[cfg(feature = "unicode-names")]
44
use unicode_names2;
55

6-
#[cfg(feature="wtf8")]
6+
#[cfg(not(feature = "unicode-names"))]
7+
use errors::PyParseError;
8+
9+
#[cfg(feature = "wtf8")]
710
use wtf8;
811

9-
use helpers::StrSpan;
10-
use errors::PyParseError;
1112
use ast::*;
13+
use helpers::StrSpan;
1214

13-
#[cfg(feature="wtf8")]
15+
#[cfg(feature = "wtf8")]
1416
fn cp_from_char(c: char) -> wtf8::CodePoint {
1517
wtf8::CodePoint::from_char(c)
1618
}
17-
#[cfg(feature="wtf8")]
19+
#[cfg(feature = "wtf8")]
1820
fn cp_from_u32(n: u32) -> Option<wtf8::CodePoint> {
1921
wtf8::CodePoint::from_u32(n)
2022
}
21-
#[cfg(not(feature="wtf8"))]
23+
#[cfg(not(feature = "wtf8"))]
2224
fn cp_from_char(c: char) -> char {
2325
c
2426
}
25-
#[cfg(not(feature="wtf8"))]
27+
#[cfg(not(feature = "wtf8"))]
2628
fn cp_from_u32(n: u32) -> Option<char> {
2729
::std::char::from_u32(n)
2830
}
2931

30-
#[cfg(feature="unicode-names")]
32+
#[cfg(feature = "unicode-names")]
3133
named!(unicode_escaped_name<StrSpan, Option<PyStringCodePoint>>,
3234
map!(
3335
preceded!(char!('N'), delimited!(char!('{'), many1!(none_of!("}")), char!('}'))),
3436
|name: Vec<char>| unicode_names2::character(&name.iter().collect::<String>()).map(cp_from_char)
3537
)
3638
);
3739

38-
#[cfg(not(feature="unicode-names"))]
39-
pub fn unicode_escaped_name(i: StrSpan) -> Result<(StrSpan, Option<PyStringCodePoint>), ::nom::Err<StrSpan>> {
40-
Err(::nom::Err::Error(::nom::Context::Code(i, ::nom::ErrorKind::Custom(PyParseError::DisabledFeature.into()))))
40+
#[cfg(not(feature = "unicode-names"))]
41+
pub fn unicode_escaped_name(
42+
i: StrSpan,
43+
) -> Result<(StrSpan, Option<PyStringCodePoint>), ::nom::Err<StrSpan>> {
44+
Err(::nom::Err::Error(::nom::Context::Code(
45+
i,
46+
::nom::ErrorKind::Custom(PyParseError::DisabledFeature.into()),
47+
)))
4148
}
4249

4350
named!(escapedchar<StrSpan, Option<PyStringCodePoint>>,
@@ -154,4 +161,3 @@ named!(pub string<StrSpan, PyString>,
154161
) >> (PyString { prefix: prefix.to_string(), content: content })
155162
)
156163
);
157-

0 commit comments

Comments
 (0)