MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_literal

Method parse_literal

crates/common/src/format.rs:1209–1228  ·  view source on GitHub ↗
(text: &Wtf8)

Source from the content-addressed store, hash-verified

1207 }
1208
1209 fn parse_literal(text: &Wtf8) -> Result<(FormatPart, &Wtf8), FormatParseError> {
1210 let mut cur_text = text;
1211 let mut result_string = Wtf8Buf::new();
1212 while !cur_text.is_empty() {
1213 match Self::parse_literal_single(cur_text) {
1214 Ok((next_char, remaining)) => {
1215 result_string.push(next_char);
1216 cur_text = remaining;
1217 }
1218 Err(err) => {
1219 return if !result_string.is_empty() {
1220 Ok((FormatPart::Literal(result_string), cur_text))
1221 } else {
1222 Err(err)
1223 };
1224 }
1225 }
1226 }
1227 Ok((FormatPart::Literal(result_string), "".as_ref()))
1228 }
1229
1230 fn parse_part_in_brackets(text: &Wtf8) -> Result<FormatPart, FormatParseError> {
1231 let mut chars = text.code_points().peekable();

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
LiteralClass · 0.50
ErrClass · 0.50
is_emptyMethod · 0.45
pushMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected