E4215#
Compiler diagnostic name: expect_template_string.
This diagnostic described a non-template right-hand side of the <+ operator
and is not emitted by the current compiler. The parser now rejects this syntax
with E3002.
The <+ template-writing operator writes a string template to the value on its
left. The right-hand side must be a string literal, an interpolated string, or a
multiline string template. Other expressions cannot be expanded as template
content.
Erroneous example#
pub fn render(value : String) -> String {
let builder = StringBuilder()
builder <+ value
builder.to_string()
}
The right-hand side is a variable reference, not a template string.
Suggestion#
Use a string template on the right-hand side.
pub fn render(value : String) -> String {
let builder = StringBuilder()
builder <+ "\{value}"
builder.to_string()
}