You can append one string to another using Rust's built-in string concatenation methods. You can take advantage of the push_str
method which can append a string slice to the end of another string.
main.rs141 chars9 lines
In this example, hello
is a mutable String with an initial value of "Hello, "
. The world
string slice is then appended to hello
using the push_str
method. Finally, hello
is printed to the console which will display "Hello, world!"
.
gistlibby LogSnag