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

Function interpolation_to_expr

crates/vm/src/stdlib/_ast/string.rs:719–737  ·  view source on GitHub ↗
(
    vm: &VirtualMachine,
    interpolation: TStringInterpolation,
)

Source from the content-addressed store, hash-verified

717}
718
719pub(super) fn interpolation_to_expr(
720 vm: &VirtualMachine,
721 interpolation: TStringInterpolation,
722) -> PyResult<ast::Expr> {
723 let part = TemplateStrPart::Interpolation(interpolation);
724 let elements = template_parts_to_elements(vm, vec![part].into_boxed_slice())?;
725 let range = TextRange::default();
726 let tstring = ast::TString {
727 range,
728 node_index: Default::default(),
729 elements,
730 flags: ast::TStringFlags::empty(),
731 };
732 Ok(ast::Expr::TString(ast::ExprTString {
733 node_index: Default::default(),
734 range,
735 value: ast::TStringValue::single(tstring),
736 }))
737}
738
739fn template_parts_to_elements(
740 vm: &VirtualMachine,

Callers 1

ast_from_objectMethod · 0.85

Calls 2

InterpolationClass · 0.85

Tested by

no test coverage detected