From: acevest Date: Tue, 21 Sep 2021 00:59:44 +0000 (+0800) Subject: add rust owner ship X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=224f9d4cf437dfb81270c90624774072ca278bdf;p=acecode.git add rust owner ship --- diff --git a/learn/rust/ownership/Cargo.lock b/learn/rust/ownership/Cargo.lock new file mode 100644 index 0000000..21b71f8 --- /dev/null +++ b/learn/rust/ownership/Cargo.lock @@ -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 index 0000000..0933548 --- /dev/null +++ b/learn/rust/ownership/Cargo.toml @@ -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 index 0000000..f1febb5 --- /dev/null +++ b/learn/rust/ownership/src/main.rs @@ -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) +}