organizado en carpetas
This commit is contained in:
8
curso_tinchicusls/vectores/Cargo.toml
Normal file
8
curso_tinchicusls/vectores/Cargo.toml
Normal 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]
|
||||
15
curso_tinchicusls/vectores/src/main.rs
Normal file
15
curso_tinchicusls/vectores/src/main.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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])
|
||||
}
|
||||
Reference in New Issue
Block a user