vectores
This commit is contained in:
@@ -3,4 +3,5 @@ https://tinchicus.com/2022/09/26/rust-listado-del-curso-inicial/
|
|||||||
- https://tinchicus.com/2022/06/01/rust-usando-a-cargo/ (hola_mundo)
|
- https://tinchicus.com/2022/06/01/rust-usando-a-cargo/ (hola_mundo)
|
||||||
- https://tinchicus.com/2022/06/03/rust-strings/ (cadenas)
|
- https://tinchicus.com/2022/06/03/rust-strings/ (cadenas)
|
||||||
- https://tinchicus.com/2022/06/06/rust-arrays/ (arreglos)
|
- https://tinchicus.com/2022/06/06/rust-arrays/ (arreglos)
|
||||||
- https://tinchicus.com/2022/06/07/rust-vector/ (vectores)
|
- https://tinchicus.com/2022/06/07/rust-vector/ (vectores)
|
||||||
|
- https://tinchicus.com/2022/06/08/rust-tuple/ (tupla)
|
||||||
8
vectores/Cargo.toml
Normal file
8
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]
|
||||||
16
vectores/src/main.rs
Normal file
16
vectores/src/main.rs
Normal 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])
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user