]> Zhao Yanbai Git Server - acecode.git/commitdiff
add rust owner ship
authoracevest <zhaoyanbai@126.com>
Tue, 21 Sep 2021 00:59:44 +0000 (08:59 +0800)
committeracevest <zhaoyanbai@126.com>
Tue, 21 Sep 2021 00:59:44 +0000 (08:59 +0800)
learn/rust/ownership/Cargo.lock [new file with mode: 0644]
learn/rust/ownership/Cargo.toml [new file with mode: 0644]
learn/rust/ownership/src/main.rs [new file with mode: 0644]

diff --git a/learn/rust/ownership/Cargo.lock b/learn/rust/ownership/Cargo.lock
new file mode 100644 (file)
index 0000000..21b71f8
--- /dev/null
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "ownership"
+version = "0.1.0"
diff --git a/learn/rust/ownership/Cargo.toml b/learn/rust/ownership/Cargo.toml
new file mode 100644 (file)
index 0000000..0933548
--- /dev/null
@@ -0,0 +1,8 @@
+[package]
+name = "ownership"
+version = "0.1.0"
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/learn/rust/ownership/src/main.rs b/learn/rust/ownership/src/main.rs
new file mode 100644 (file)
index 0000000..f1febb5
--- /dev/null
@@ -0,0 +1,11 @@
+
+fn main() {
+    let s1 = String::from("hello");
+    take_ownership(s1);
+    println!("{}", s1);
+}
+
+
+fn take_ownership(s: String) {
+    println!("take ownership of {}", s)
+}