Template strings in Rust
Template strings have become widespread in modern programming languages, but Rust is a notable exception. Here I want to shed light on the design space and rationale for template strings in Rust, and present a proposal.
Motivation
Section titled “Motivation”Template strings allow interpolating values in a string. Some languages also support custom template strings for specialized use cases:
// template string in JavaScript`Hello, ${person.name}!`
// tagged template stringsql`SELECT * FROM users WHERE id = ${handle} ORDER BY ${sortField};`// this is equivalent to...sql( ["SELECT * FROM users WHERE id = ", " ORDER BY ", ";"], handle, sortField)