rustrust string append char
Rust strings are immutable, meaning that once created, they cannot be changed. However, it is possible to append a single character to a string using the push method.
Example code
let mut s = String::from("Hello");
s.push('!');
Output example
Hello!
The code above creates a mutable string s with the value Hello. The push method is then used to append the character ! to the end of the string. The result is the string Hello!.
Helpful links
More of Rust
- How to use non-capturing groups in Rust regex?
- How to replace a capture group using Rust regex?
- How to print a Rust HashMap?
- How to replace strings using Rust regex?
- Regex example to match multiline string in Rust?
- How to use regex lookbehind in Rust?
- How to match the end of a line in a Rust regex?
- How to create a HashSet from a Range in Rust?
- How to lock a Rust HashMap?
- How to sort the keys in a Rust HashMap?
See more codes...