interpolate
interpolate copied to clipboard
Question about nesting
In JS:
var x = 1;
var a = "asd"
var s = `a ${a + ` x${x + 1} y`} b`;
console.log(s); // a asd x2 y b
Would this be the Rust equivalent?
let x = 1;
let a = "asd";
let s = s!("a ${a.to_string() + &s!(" x${x + 1} y")} b");
or alternatively:
let x = 1;
let a = s!("asd");
let s = s!("a ${a + &s!(" x${x + 1} y")} b");
?
Perhaps? But those are so complicated to read that they feel like the antithesis of what this crate aims to accomplish: interpolation that is very simple and natural to read and write. I had a hard time reading any of those examples. I'd prefer:
let nested = s!("{a} x{x+1} y");
let s = s!("a {nested} b");
(note: I'm using syntax that removes the $)