From 7fdb9249afe07c75ad8bea568195a3a8d979d73a Mon Sep 17 00:00:00 2001 From: garhve Date: Fri, 30 Dec 2022 13:47:02 +0800 Subject: finish chapter 8 --- .../chapter-8-common-collections/string/src/main.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rust/theBook/chapter-8-common-collections/string/src/main.rs (limited to 'rust/theBook/chapter-8-common-collections/string/src/main.rs') diff --git a/rust/theBook/chapter-8-common-collections/string/src/main.rs b/rust/theBook/chapter-8-common-collections/string/src/main.rs new file mode 100644 index 0000000..c28e5b1 --- /dev/null +++ b/rust/theBook/chapter-8-common-collections/string/src/main.rs @@ -0,0 +1,18 @@ +fn main() { + let mut m = String::from("Hello"); + println!("{}",m); + + m.push_str(" World"); + println!("{}",m); + + let p = ", World"; + let l = m + &p; + println!("{}",l); + + let z = "tic"; + let x = "tac"; + let c = "toe"; + + let s = format!("{z}-{x}{c}"); + println!("{s}"); +} -- cgit v1.2.3-70-g09d2