(
format_spec: Option<Box<ast::InterpolatedStringFormatSpec>>,
)
| 235 | } |
| 236 | |
| 237 | fn 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 | |
| 265 | fn ruff_fstring_element_to_ruff_fstring_part( |
| 266 | element: ast::InterpolatedStringElement, |
no test coverage detected