MCPcopy Create free account
hub / github.com/astral-sh/ruff / parse_octet

Method parse_octet

crates/ruff_python_parser/src/string.rs:182–199  ·  view source on GitHub ↗
(&mut self, o: u8)

Source from the content-addressed store, hash-verified

180 }
181
182 fn parse_octet(&mut self, o: u8) -> char {
183 let mut radix_bytes = [o, 0, 0];
184 let mut len = 1;
185
186 while len < 3 {
187 let Some(b'0'..=b'7') = self.peek_byte() else {
188 break;
189 };
190
191 radix_bytes[len] = self.next_byte().unwrap();
192 len += 1;
193 }
194
195 // OK because radix_bytes is always going to be in the ASCII range.
196 let radix_str = std::str::from_utf8(&radix_bytes[..len]).expect("ASCII bytes");
197 let value = u32::from_str_radix(radix_str, 8).unwrap();
198 char::from_u32(value).unwrap()
199 }
200
201 fn parse_unicode_name(&mut self) -> Result<char, LexicalError> {
202 let start_pos = self.position();

Callers 1

parse_escaped_charMethod · 0.80

Calls 3

peek_byteMethod · 0.80
next_byteMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected