rustHow to concat strings in Rust
Strings in Rust can be concatenated using the +
operator. The following ## Code example shows how to concatenate two strings:
let s1 = "Hello";
let s2 = "World";
let s3 = s1 + " " + s2;
println!("{}", s3);
Output
Hello World
The code above does the following:
- Declares two strings
s1
ands2
with the valuesHello
andWorld
respectively. - Concatenates the two strings using the
+
operator and assigns the result tos3
. - Prints the value of
s3
to the console.
For more information on string concatenation in Rust, please refer to the following links:
More of Rust
- How to use regex with bytes in Rust?
- How to use regex to match a double quote in Rust?
- How to replace a capture group using Rust regex?
- How to use regex captures in Rust?
- How to convert JSON to a struct in Rust?
- How to get an element from a HashSet in Rust?
- How to implement PartialEq for a Rust HashMap?
- How to get a capture group using Rust regex?
- How to use regex lookahead in Rust?
- How to parse JSON string in Rust?
See more codes...