How to combine a string with a dynamic double-quoted substring in Rust

1 Answer

0 votes
fn main() {
    let dynamicsubstring1 = "double-quoted substring1";
    let dynamicsubstring2 = "double-quoted substring2";

    // Using formatted string interpolation
    let string = format!(
        "This is a string with \"{}\", and \"{}\" inside.",
        dynamicsubstring1, dynamicsubstring2
    );

    println!("{}", string);
}


 
 
/*
run:
 
This is a string with "double-quoted substring1", and "double-quoted substring2" inside.

*/

 



answered May 13 by avibootz
...