This commit is contained in:
2023-05-29 09:15:22 +02:00
parent 7abcad7453
commit 5969526dd1
3 changed files with 26 additions and 1 deletions

View File

@@ -4,3 +4,4 @@ https://tinchicus.com/2022/09/26/rust-listado-del-curso-inicial/
- https://tinchicus.com/2022/06/03/rust-strings/ (cadenas)
- https://tinchicus.com/2022/06/06/rust-arrays/ (arreglos)
- https://tinchicus.com/2022/06/07/rust-vector/ (vectores)
- https://tinchicus.com/2022/06/08/rust-tuple/ (tupla)

8
vectores/Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "vectores"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

16
vectores/src/main.rs Normal file
View File

@@ -0,0 +1,16 @@
// se diferencia de los arrays en que se puede modificar el tamaño
fn main() {
// definición más explícita
let mut _mi_vector: Vec<i32>=Vec::new();
// otra forma expecificando el tipo
let mut _mi_vector2=vec![4i32,2,4,8,16];
// otra forma
let mut _mi_vector3=[2,4,8,16];
// solo definimos el tamaño
let mut _mi_vector4: Vec<i64>=Vec::with_capacity(30);
// con un iterador
let _mi_vector5: Vec<u64> = (0..10).collect();
println!("{}",_mi_vector5[7])
}