Commit e2327f0 1 parent eeb2e5b commit e2327f0 Copy full SHA for e2327f0
File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,13 @@ impl FromStr for TokenStream {
182
182
183
183
fn from_str ( src : & str ) -> Result < TokenStream , LexError > {
184
184
// Create a dummy file & add it to the source map
185
- let cursor = get_cursor ( src) ;
185
+ let mut cursor = get_cursor ( src) ;
186
+
187
+ // Strip a byte order mark if present
188
+ const BYTE_ORDER_MARK : & str = "\u{feff} " ;
189
+ if cursor. starts_with ( BYTE_ORDER_MARK ) {
190
+ cursor = cursor. advance ( BYTE_ORDER_MARK . len ( ) ) ;
191
+ }
186
192
187
193
parse:: token_stream ( cursor)
188
194
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ pub(crate) struct Cursor<'a> {
14
14
}
15
15
16
16
impl < ' a > Cursor < ' a > {
17
- fn advance ( & self , bytes : usize ) -> Cursor < ' a > {
17
+ pub fn advance ( & self , bytes : usize ) -> Cursor < ' a > {
18
18
let ( _front, rest) = self . rest . split_at ( bytes) ;
19
19
Cursor {
20
20
rest,
@@ -23,7 +23,7 @@ impl<'a> Cursor<'a> {
23
23
}
24
24
}
25
25
26
- fn starts_with ( & self , s : & str ) -> bool {
26
+ pub fn starts_with ( & self , s : & str ) -> bool {
27
27
self . rest . starts_with ( s)
28
28
}
29
29
You can’t perform that action at this time.
0 commit comments