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

Function ruff_format_spec_to_joined_str

crates/vm/src/stdlib/_ast/string.rs:237–263  ·  view source on GitHub ↗
(
    format_spec: Option<Box<ast::InterpolatedStringFormatSpec>>,
)

Source from the content-addressed store, hash-verified

235}
236
237fn ruff_format_spec_to_joined_str(
238 format_spec: Option<Box<ast::InterpolatedStringFormatSpec>>,
239) -> Option<Box<JoinedStr>> {
240 match format_spec {
241 None => None,
242 Some(format_spec) => {
243 let ast::InterpolatedStringFormatSpec {
244 range,
245 elements,
246 node_index: _,
247 } = *format_spec;
248 let range = if range.start() > ruff_text_size::TextSize::from(0) {
249 TextRange::new(
250 range.start() - ruff_text_size::TextSize::from(1),
251 range.end(),
252 )
253 } else {
254 range
255 };
256 let values: Vec<_> = ruff_fstring_element_into_iter(elements)
257 .map(ruff_fstring_element_to_joined_str_part)
258 .collect();
259 let values = normalize_joined_str_parts(values).into_boxed_slice();
260 Some(Box::new(JoinedStr { range, values }))
261 }
262 }
263}
264
265fn ruff_fstring_element_to_ruff_fstring_part(
266 element: ast::InterpolatedStringElement,

Calls 8

newFunction · 0.85
collectMethod · 0.80
SomeClass · 0.50
startMethod · 0.45
endMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected