File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 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 {
182182
183183 fn from_str ( src : & str ) -> Result < TokenStream , LexError > {
184184 // 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+ }
186192
187193 parse:: token_stream ( cursor)
188194 }
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ pub(crate) struct Cursor<'a> {
1414}
1515
1616impl < ' a > Cursor < ' a > {
17- fn advance ( & self , bytes : usize ) -> Cursor < ' a > {
17+ pub fn advance ( & self , bytes : usize ) -> Cursor < ' a > {
1818 let ( _front, rest) = self . rest . split_at ( bytes) ;
1919 Cursor {
2020 rest,
@@ -23,7 +23,7 @@ impl<'a> Cursor<'a> {
2323 }
2424 }
2525
26- fn starts_with ( & self , s : & str ) -> bool {
26+ pub fn starts_with ( & self , s : & str ) -> bool {
2727 self . rest . starts_with ( s)
2828 }
2929
You can’t perform that action at this time.
0 commit comments