To concatenate two strings in Rust, you can use the `+` operator or the `format!()` macro.
In this example,
str1
and str2
with values "Hello"
and "World"
respectively.str2
to str1
using the `+` operator and store the result in a variable named result
.result
to the console.fn main() {
let str1 = String::from("Hello");
let str2 = String::from("World");
let result = str1 + &str2;
println!("{}", result);
}
HelloWorld
In this tutorial, we learned How to Concatenate Two Strings in Rust language with well detailed examples.