E4215#
Compiler diagnostic name: expect_template_string.
この診断は <+ 演算子の右辺がテンプレートでない場合を説明するもので、現在のコンパイラでは出力されません。現在はパーサーがこの構文を 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()
}