@@ -28,8 +28,6 @@ pub use self::Alignment::*;
28
28
pub use self :: Flag :: * ;
29
29
pub use self :: Count :: * ;
30
30
31
- extern crate syntax;
32
-
33
31
use std:: str;
34
32
use std:: string;
35
33
use std:: iter;
@@ -152,8 +150,8 @@ pub struct Parser<'a> {
152
150
pub errors : Vec < ParseError > ,
153
151
/// Current position of implicit positional argument pointer
154
152
curarg : usize ,
155
- /// The style of the string (raw or not) , used to position spans correctly
156
- style : syntax :: ast :: StrStyle ,
153
+ /// `Some(raw count)` when the string is "raw" , used to position spans correctly
154
+ style : Option < usize > ,
157
155
/// How many newlines have been seen in the string so far, to adjust the error spans
158
156
seen_newlines : usize ,
159
157
}
@@ -162,10 +160,7 @@ impl<'a> Iterator for Parser<'a> {
162
160
type Item = Piece < ' a > ;
163
161
164
162
fn next ( & mut self ) -> Option < Piece < ' a > > {
165
- let raw = match self . style {
166
- syntax:: ast:: StrStyle :: Raw ( raw) => raw as usize + self . seen_newlines ,
167
- _ => 0 ,
168
- } ;
163
+ let raw = self . style . map ( |raw| raw + self . seen_newlines ) . unwrap_or ( 0 ) ;
169
164
if let Some ( & ( pos, c) ) = self . cur . peek ( ) {
170
165
match c {
171
166
'{' => {
@@ -208,7 +203,7 @@ impl<'a> Iterator for Parser<'a> {
208
203
209
204
impl < ' a > Parser < ' a > {
210
205
/// Creates a new parser for the given format string
211
- pub fn new ( s : & ' a str , style : syntax :: ast :: StrStyle ) -> Parser < ' a > {
206
+ pub fn new ( s : & ' a str , style : Option < usize > ) -> Parser < ' a > {
212
207
Parser {
213
208
input : s,
214
209
cur : s. char_indices ( ) . peekable ( ) ,
@@ -278,10 +273,7 @@ impl<'a> Parser<'a> {
278
273
/// found, an error is emitted.
279
274
fn must_consume ( & mut self , c : char ) {
280
275
self . ws ( ) ;
281
- let raw = match self . style {
282
- syntax:: ast:: StrStyle :: Raw ( raw) => raw as usize ,
283
- _ => 0 ,
284
- } ;
276
+ let raw = self . style . unwrap_or ( 0 ) ;
285
277
286
278
let padding = raw + self . seen_newlines ;
287
279
if let Some ( & ( pos, maybe) ) = self . cur . peek ( ) {
0 commit comments