Skip to content

Commit 844ccfd

Browse files
committed
Add support for older Rust versions (down to 1.25.0).
1 parent b112e46 commit 844ccfd

File tree

6 files changed

+57
-63
lines changed

6 files changed

+57
-63
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: rust
22
rust:
3+
- 1.25.0
34
- stable
45
- beta
56
- nightly

src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub enum Uop {
9999

100100
impl fmt::Display for Uop {
101101
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
102-
write!(f, "{}", match self {
102+
write!(f, "{}", match *self {
103103
Uop::Plus => "+",
104104
Uop::Minus => "-",
105105
Uop::Invert => "~",
@@ -144,7 +144,7 @@ pub enum Bop {
144144

145145
impl fmt::Display for Bop {
146146
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
147-
write!(f, "{}", match self {
147+
write!(f, "{}", match *self {
148148
Bop::Add => "+",
149149
Bop::Sub => "-",
150150
Bop::Mult => "*",
@@ -290,7 +290,7 @@ pub enum AugAssignOp {
290290

291291
impl fmt::Display for AugAssignOp {
292292
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
293-
write!(f, "{}", match self {
293+
write!(f, "{}", match *self {
294294
AugAssignOp::Add => "+=",
295295
AugAssignOp::Sub => "-=",
296296
AugAssignOp::Mult => "*=",

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ named!(pub spaces_nl<StrSpan, ()>,
6565
pub fn spaces_nonl(i: StrSpan) -> Result<(StrSpan, ()), ::nom::Err<StrSpan>> {
6666
let mut it = i.fragment.chars().enumerate().peekable();
6767
while let Some((index, c)) = it.next() {
68-
let next_char = it.peek().map(|(_,c)|*c);
68+
let next_char = it.peek().map(|&(_,c)|c);
6969
match c {
7070
' ' | '\t' | '\x0c' => (),
7171
'\\' if next_char.unwrap_or(' ') == '\n' => {it.next();},

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
//! # Example
2323
//!
2424
//! ```
25-
//! extern crate python_parser;
2625
//! use python_parser::ast::*;
2726
//! let code = "print(2 + 3, fd=sys.stderr)";
2827
//! let ast = python_parser::file_input(python_parser::make_strspan(code))

src/strings.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,13 @@ named!(escapedchar<StrSpan, Option<PyStringCodePoint>>,
5757
unicode_names2::character(&name.iter().collect::<String>()).map(cp_from_char)
5858
}
5959
| preceded!(char!('u'), count!(one_of!("0123456789abcdefABCDEF"), 4)) => { |v: Vec<char>| {
60-
let it: Vec<u32> = v.iter().map(|c| c.to_digit(16).unwrap()).collect();
61-
if let [d1, d2, d3, d4] = &it[..] {
62-
cp_from_u32((d1 << 12) + (d2 << 8) + (d3 << 4) + d4)
63-
}
64-
else { unreachable!() }
60+
let v: Vec<u32> = v.iter().map(|c| c.to_digit(16).unwrap()).collect();
61+
cp_from_u32((v[0] << 12) + (v[1] << 8) + (v[2] << 4) + v[3])
6562
}}
6663
| preceded!(char!('U'), count!(one_of!("0123456789abcdefABCDEF"), 8)) => { |v: Vec<char>| {
67-
let it: Vec<u32> = v.iter().map(|c| c.to_digit(16).unwrap()).collect();
68-
if let [d1, d2, d3, d4, d5, d6, d7, d8] = &it[..] {
69-
cp_from_u32((d1 << 28) + (d2 << 24) + (d3 << 20) + (d4 << 16) +
70-
(d5 << 12) + (d6 << 8) + (d7 << 4) + d8)
71-
}
72-
else { unreachable!() }
64+
let v: Vec<u32> = v.iter().map(|c| c.to_digit(16).unwrap()).collect();
65+
cp_from_u32((v[0] << 28) + (v[1] << 24) + (v[2] << 20) + (v[3] << 16) +
66+
(v[4] << 12) + (v[5] << 8 ) + (v[6] << 4 ) + v[7])
7367
}}
7468
)
7569
)

0 commit comments

Comments
 (0)