String Literal
String Both have different ownership and mutability characteristics.
String literal: string local variable, stored on stack
let a:string = "test";
Operations on String
///////////// Concatenate /////////////////////////
// push_str()
let s2 = String::from("Hello");
s2.push_str(" World"); //push_str() appends string.
s2.push(' k'); //push() appends 1 character
// +
let s1 = String::from("Test");
let s2 = String::from("Foo");
let s3 = s1 + &s2; //Why reference. Operator + uses add method `fn add(self, s: &str) -> String {..}`
//println!("{}",s1); //Since s1 is moved not copied
// format()
let s1 = String::from("Test");
let s2 = String::from("Foo");
let s3 = format!("{} {}",s1,s2); //Test Foo
///////////// Reverse the string ////////////////
strA = strA.chars().rev().collect::<String>();
///////////// Tokenize ////////////////////
let a = "40:20".to_string();
let vec:Vec <&str> = a.split(':').collect();
//////////// Conversion //////////////////
let a = my_string.parse::<i32>().unwrap(); //string to int
let mut strA = a.to_string(); //int to string
/////////// Print Characters ////////////
let hello = "Здравствуйте";
for a in hello.chars() {
println!("{}",a)
}