Skip to content

Commit

Permalink
Run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Oct 28, 2018
1 parent 7f8337d commit 306f4db
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/strings.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
use nom::anychar;

#[cfg(feature="unicode-names")]
#[cfg(feature = "unicode-names")]
use unicode_names2;

#[cfg(feature="wtf8")]
#[cfg(feature = "wtf8")]
use wtf8;

use helpers::StrSpan;
use errors::PyParseError;
use ast::*;
use errors::PyParseError;
use helpers::StrSpan;

#[cfg(feature="wtf8")]
#[cfg(feature = "wtf8")]
fn cp_from_char(c: char) -> wtf8::CodePoint {
wtf8::CodePoint::from_char(c)
}
#[cfg(feature="wtf8")]
#[cfg(feature = "wtf8")]
fn cp_from_u32(n: u32) -> Option<wtf8::CodePoint> {
wtf8::CodePoint::from_u32(n)
}
#[cfg(not(feature="wtf8"))]
#[cfg(not(feature = "wtf8"))]
fn cp_from_char(c: char) -> char {
c
}
#[cfg(not(feature="wtf8"))]
#[cfg(not(feature = "wtf8"))]
fn cp_from_u32(n: u32) -> Option<char> {
::std::char::from_u32(n)
}

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

#[cfg(not(feature="unicode-names"))]
pub fn unicode_escaped_name(i: StrSpan) -> Result<(StrSpan, Option<PyStringCodePoint>), ::nom::Err<StrSpan>> {
Err(::nom::Err::Error(::nom::Context::Code(i, ::nom::ErrorKind::Custom(PyParseError::DisabledFeature.into()))))
#[cfg(not(feature = "unicode-names"))]
pub fn unicode_escaped_name(
i: StrSpan,
) -> Result<(StrSpan, Option<PyStringCodePoint>), ::nom::Err<StrSpan>> {
Err(::nom::Err::Error(::nom::Context::Code(
i,
::nom::ErrorKind::Custom(PyParseError::DisabledFeature.into()),
)))
}

named!(escapedchar<StrSpan, Option<PyStringCodePoint>>,
Expand Down Expand Up @@ -154,4 +159,3 @@ named!(pub string<StrSpan, PyString>,
) >> (PyString { prefix: prefix.to_string(), content: content })
)
);

0 comments on commit 306f4db

Please sign in to comment.