Add vectors
parent
c9491c2874
commit
1e7e663d48
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "vectors"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
@ -0,0 +1,16 @@
|
|||||||
|
fn main() {
|
||||||
|
// Create Vector
|
||||||
|
let v1: Vec<i32> = Vec::new();
|
||||||
|
|
||||||
|
// Create Vector with initial elements
|
||||||
|
let v2 = vec![1, 2, 3];
|
||||||
|
|
||||||
|
// Mutate Vector
|
||||||
|
let mut v3 = vec![1, 2, 3];
|
||||||
|
v3.push(4);
|
||||||
|
|
||||||
|
// Iterating over immutable references of v3
|
||||||
|
for i in &v3 {
|
||||||
|
print!("{}", i);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue