summaryrefslogtreecommitdiff
path: root/rust/chap4/vecs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/chap4/vecs.rs')
-rw-r--r--rust/chap4/vecs.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/chap4/vecs.rs b/rust/chap4/vecs.rs
new file mode 100644
index 0000000..b0a76be
--- /dev/null
+++ b/rust/chap4/vecs.rs
@@ -0,0 +1,11 @@
+fn main() {
+ let mut v: Vec<i32> = vec![1, 2, 3];
+
+ /* Push an item calling method direct from Vec definition */
+ Vec::push(&mut v, 4);
+
+ /* Push an item calling the method via its object */
+ v.push(5);
+
+ println!("{:?}", v);
+}