summaryrefslogtreecommitdiff
path: root/rust/theBook/chapter-8-common-collections/string
diff options
context:
space:
mode:
Diffstat (limited to 'rust/theBook/chapter-8-common-collections/string')
-rw-r--r--rust/theBook/chapter-8-common-collections/string/Cargo.toml8
-rw-r--r--rust/theBook/chapter-8-common-collections/string/src/main.rs18
2 files changed, 26 insertions, 0 deletions
diff --git a/rust/theBook/chapter-8-common-collections/string/Cargo.toml b/rust/theBook/chapter-8-common-collections/string/Cargo.toml
new file mode 100644
index 0000000..9eed48f
--- /dev/null
+++ b/rust/theBook/chapter-8-common-collections/string/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "string"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
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}");
+}