Debian Codegraph @

src/stream.rs

raw symbols SCIP
1 // Copyright 2016 the SimpleCSS Authors
2 // SPDX-License-Identifier: Apache-2.0 OR MIT
3
4 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/;
5
6 use craterust-analyzer cargo simplecss 0.2.2 crate/::{Errorrust-analyzer cargo simplecss 0.2.2 Error#, TextPosrust-analyzer cargo simplecss 0.2.2 TextPos#};
7
8 trait CssCharExtrust-analyzer cargo simplecss 0.2.2 stream/CssCharExt# {
9 fn is_name_startrust-analyzer cargo simplecss 0.2.2 stream/CssCharExt#is_name_start().(&self) -> bool;
10 fn is_name_charrust-analyzer cargo simplecss 0.2.2 stream/CssCharExt#is_name_char().(&self) -> bool;
11 fn is_non_asciirust-analyzer cargo simplecss 0.2.2 stream/CssCharExt#is_non_ascii().(&self) -> bool;
12 fn is_escaperust-analyzer cargo simplecss 0.2.2 stream/CssCharExt#is_escape().(&self) -> bool;
13 }
14
15 impl CssCharExtrust-analyzer cargo simplecss 0.2.2 stream/CssCharExt# for char {
16 #[inline]
17 fn is_name_startrust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_name_start().(&self) -> bool {
18 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
19 '_' | 'a'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'z' | 'A'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'Z' => true,
20 _ => self.is_non_asciirust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_non_ascii().() || self.is_escaperust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_escape().(),
21 }
22 }
23
24 #[inline]
25 fn is_name_charrust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_name_char().(&self) -> bool {
26 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
27 '_' | 'a'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'z' | 'A'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'Z' | '0'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'9' | '-' => true,
28 _ => self.is_non_asciirust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_non_ascii().() || self.is_escaperust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_escape().(),
29 }
30 }
31
32 #[inline]
33 fn is_non_asciirust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_non_ascii().(&self) -> bool {
34 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().237
35 }
36
37 #[inline]
38 fn is_escaperust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_escape().(&self) -> bool {
39 // TODO: this
40 false
41 }
42 }
43
44 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
45 pub(craterust-analyzer cargo simplecss 0.2.2 crate/) struct Streamrust-analyzer cargo simplecss 0.2.2 stream/Stream#<'a> {
46 textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text.: &'a str,
47 posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.: usize,
48 endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end.: usize,
49 }
50
51 impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a str> for Streamrust-analyzer cargo simplecss 0.2.2 stream/Stream#<'a> {
52 fn fromrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`][`From<&'a str>`]from().(text: &'a str) -> Selfrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`][`From<&'a str>`] {
53 Streamrust-analyzer cargo simplecss 0.2.2 stream/Stream#::newrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]new().(text)
54 }
55 }
56
57 impl<'a> Streamrust-analyzer cargo simplecss 0.2.2 stream/Stream#<'a> {
58 pub fn newrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]new().(text: &'a str) -> Selfrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`] {
59 Streamrust-analyzer cargo simplecss 0.2.2 stream/Stream# {
60 textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text.,
61 posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.: 0,
62 endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end.: text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().(),
63 }
64 }
65
66 #[inline]
67 pub fn posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]pos().(&self) -> usize {
68 self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.
69 }
70
71 #[inline]
72 pub fn jump_to_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]jump_to_end().(&mut self) {
73 self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. = self.endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end.;
74 }
75
76 #[inline]
77 pub fn at_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]at_end().(&self) -> bool {
78 self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().self.endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end.
79 }
80
81 #[inline]
82 pub fn curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u8, Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
83 if self.at_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]at_end().() {
84 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo simplecss 0.2.2 Error#::UnexpectedEndOfStreamrust-analyzer cargo simplecss 0.2.2 Error#UnexpectedEndOfStream#);
85 }
86
87 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.curr_byte_uncheckedrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte_unchecked().())
88 }
89
90 #[inline]
91 pub fn curr_byte_uncheckedrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte_unchecked().(&self) -> u8 {
92 self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
93 }
94
95 #[inline]
96 pub fn next_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]next_byte().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u8, Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
97 if self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().self.endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end. {
98 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo simplecss 0.2.2 Error#::UnexpectedEndOfStreamrust-analyzer cargo simplecss 0.2.2 Error#UnexpectedEndOfStream#);
99 }
100
101 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
102 }
103
104 #[inline]
105 pub fn advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(&mut self, n: usize) {
106 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). n <= self.endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end.);
107 self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().n;
108 }
109
110 pub fn consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_byte().(&mut self, c: u8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
111 if self.curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().c {
112 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo simplecss 0.2.2 Error#::InvalidByterust-analyzer cargo simplecss 0.2.2 Error#InvalidByte# {
113 expectedrust-analyzer cargo simplecss 0.2.2 Error#InvalidByte#expected.: c,
114 actualrust-analyzer cargo simplecss 0.2.2 Error#InvalidByte#actual.: self.curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
115 posrust-analyzer cargo simplecss 0.2.2 Error#InvalidByte#pos.: self.gen_text_posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos().(),
116 });
117 }
118
119 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
120 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
121 }
122
123 pub fn try_consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]try_consume_byte().(&mut self, c: u8) {
124 if self.curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(c) {
125 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
126 }
127 }
128
129 pub fn consume_bytesrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_bytes().<F>(&mut self, f: F) -> &'a str
130 where
131 F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(u8) -> bool,
132 {
133 let start = self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.;
134 self.skip_bytesrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_bytes().(f);
135 self.slice_backrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]slice_back().(start)
136 }
137
138 pub fn skip_bytesrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_bytes().<F>(&mut self, f: F)
139 where
140 F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(u8) -> bool,
141 {
142 while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.at_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]at_end().() && f(self.curr_byte_uncheckedrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte_unchecked().()) {
143 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
144 }
145 }
146
147 #[inline]
148 fn charsrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]chars().(&self) -> strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::Charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/Chars#<'a> {
149 self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.endrust-analyzer cargo simplecss 0.2.2 stream/Stream#end.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().()
150 }
151
152 #[inline]
153 pub fn slice_rangerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]slice_range().(&self, start: usize, end: usize) -> &'a str {
154 &self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
155 }
156
157 #[inline]
158 pub fn slice_backrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]slice_back().(&self, pos: usize) -> &'a str {
159 &self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
160 }
161
162 #[inline]
163 pub fn slice_tailrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]slice_tail().(&self) -> &'a str {
164 &self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
165 }
166
167 #[inline]
168 pub fn skip_spacesrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_spaces().(&mut self) {
169 while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.at_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]at_end().() {
170 match self.curr_byte_uncheckedrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte_unchecked().() {
171 b' ' | b'\t' | b'\n' | b'\r' | b'\x0C' => self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1),
172 _ => break,
173 }
174 }
175 }
176
177 #[inline]
178 pub fn skip_spaces_and_commentsrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_spaces_and_comments().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
179 self.skip_spacesrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_spaces().();
180 while self.curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'/') && self.next_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]next_byte().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'*') {
181 self.skip_commentrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_comment().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
182 self.skip_spacesrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_spaces().();
183 }
184
185 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
186 }
187
188 pub fn consume_identrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_ident().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'a str, Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
189 let start = self.posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]pos().();
190
191 if self.curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'-') {
192 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
193 }
194
195 let mut iter = self.charsrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]chars().();
196 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() {
197 if c.is_name_startrust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_name_start().() {
198 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(c.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().());
199 } else {
200 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo simplecss 0.2.2 Error#::InvalidIdentrust-analyzer cargo simplecss 0.2.2 Error#InvalidIdent#(self.gen_text_pos_fromrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos_from().(start)));
201 }
202 }
203
204 for c in iter {
205 if c.is_name_charrust-analyzer cargo simplecss 0.2.2 stream/impl#[char][CssCharExt]is_name_char().() {
206 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(c.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().());
207 } else {
208 break;
209 }
210 }
211
212 if start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]pos().() {
213 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo simplecss 0.2.2 Error#::InvalidIdentrust-analyzer cargo simplecss 0.2.2 Error#InvalidIdent#(self.gen_text_pos_fromrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos_from().(start)));
214 }
215
216 let name = self.slice_backrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]slice_back().(start);
217 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(name)
218 }
219
220 pub fn consume_stringrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_string().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'a str, Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
221 // Check for opening quote.
222 let quote = self.curr_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
223 if quote rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'\'' || quote rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'"' {
224 let mut prev = quote;
225 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
226
227 let start = self.posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]pos().();
228
229 while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.at_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]at_end().() {
230 let curr = self.curr_byte_uncheckedrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte_unchecked().();
231
232 // Advance until the closing quote.
233 if curr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().quote {
234 // Check for escaped quote.
235 if prev rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b'\\' {
236 break;
237 }
238 }
239
240 prev = curr;
241 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
242 }
243
244 let value = self.slice_backrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]slice_back().(start);
245
246 // Check for closing quote.
247 self.consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_byte().(quote)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
248
249 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value)
250 } else {
251 self.consume_identrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_ident().()
252 }
253 }
254
255 pub fn skip_commentrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_comment().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
256 let start = self.posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]pos().();
257 self.skip_comment_implrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_comment_impl().()
258 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| Errorrust-analyzer cargo simplecss 0.2.2 Error#::InvalidCommentrust-analyzer cargo simplecss 0.2.2 Error#InvalidComment#(self.gen_text_pos_fromrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos_from().(start)))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
259 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
260 }
261
262 fn skip_comment_implrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]skip_comment_impl().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo simplecss 0.2.2 Error#> {
263 self.consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_byte().(b'/')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
264 self.consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_byte().(b'*')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
265
266 while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.at_endrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]at_end().() {
267 let curr = self.curr_byte_uncheckedrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]curr_byte_unchecked().();
268 if curr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'*' && self.next_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]next_byte().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'/') {
269 break;
270 }
271
272 self.advancerust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]advance().(1);
273 }
274
275 self.consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_byte().(b'*')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
276 self.consume_byterust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]consume_byte().(b'/')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
277 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
278 }
279
280 #[inline(never)]
281 pub fn gen_text_posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos().(&self) -> TextPosrust-analyzer cargo simplecss 0.2.2 TextPos# {
282 let row = Selfrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]::calc_curr_rowrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]calc_curr_row().(self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text., self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.);
283 let col = Selfrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]::calc_curr_colrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]calc_curr_col().(self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text., self.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos.);
284 TextPosrust-analyzer cargo simplecss 0.2.2 TextPos#::newrust-analyzer cargo simplecss 0.2.2 impl#[TextPos]new().(row, col)
285 }
286
287 #[inline(never)]
288 pub fn gen_text_pos_fromrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos_from().(&self, pos: usize) -> TextPosrust-analyzer cargo simplecss 0.2.2 TextPos# {
289 let mut s = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self;
290 s.posrust-analyzer cargo simplecss 0.2.2 stream/Stream#pos. = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(pos, self.textrust-analyzer cargo simplecss 0.2.2 stream/Stream#text..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().());
291 s.gen_text_posrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]gen_text_pos().()
292 }
293
294 fn calc_curr_rowrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]calc_curr_row().(text: &str, end: usize) -> u32 {
295 let mut row = 1;
296 for c in &text.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
297 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'\n' {
298 row rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().1;
299 }
300 }
301
302 row
303 }
304
305 fn calc_curr_colrust-analyzer cargo simplecss 0.2.2 stream/impl#[`Stream<'a>`]calc_curr_col().(text: &str, end: usize) -> u32 {
306 let mut col = 1;
307 for c in text[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() {
308 if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'\n' {
309 break;
310 } else {
311 col rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().1;
312 }
313 }
314
315 col
316 }
317 }