Strings
String Literal
let cs: &str = "cheat sheet";
// => Share cheat sheet for developers
println!("Share {cs} for developers");
String Object
// Creating an empty string object
let my_string = String::new();
// Converting to a string object
let S_string = a_string.to_string()
// Creating an initialized string object
let lang = String::from("Rust");
println!("First language is {lang}");
.capacity()
Calculates the capacity of the string in bytes.
.contains()
Checks if the substring is contained inside the original string or not.
Pushing a single character
Pushing an entire String
let mut hi = String::from("Hey there...");
hi.push_str("How are you doing??");
// => Hey there...How are you doing??
println!("{hi}");