From e442e0e89fd3ee8db8076e53eb1c40ab69c933a2 Mon Sep 17 00:00:00 2001 From: clonbg Date: Sun, 2 Jul 2023 17:04:33 +0200 Subject: [PATCH] prop ownership --- README.md | 1 + prop/Cargo.toml | 8 ++++++++ prop/src/main.rs | 9 +++++++++ 3 files changed, 18 insertions(+) create mode 100644 prop/Cargo.toml create mode 100644 prop/src/main.rs diff --git a/README.md b/README.md index 4a3b452..fbcd133 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,4 @@ - https://tinchicus.com/2022/07/15/rust-tuple-struct/ (nuevotipo) - https://tinchicus.com/2022/07/18/rust-enum/ (enums) - https://tinchicus.com/2022/07/19/rust-patrones-y-coincidencias/ (iflet) +- https://tinchicus.com/2022/07/20/rust-ownership/ (prop) diff --git a/prop/Cargo.toml b/prop/Cargo.toml new file mode 100644 index 0000000..9ddb275 --- /dev/null +++ b/prop/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "prop" +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/prop/src/main.rs b/prop/src/main.rs new file mode 100644 index 0000000..d922089 --- /dev/null +++ b/prop/src/main.rs @@ -0,0 +1,9 @@ +fn vec_transfer(v: Vec) { + println!("v[0] en la función = {}", v[0]); +} + +fn main() { + let mivec = vec![1i32,2i32,3i32]; + vec vec_transfer(mivec); + println!("mivec[0] es = {}", mivec[0]); +}