Update Vector.md

Added a beginner-friendly solution
This commit is contained in:
Skandesh 2022-07-25 00:17:58 +05:30 committed by GitHub
parent d91ca79253
commit 661d0aa498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 1 deletions

View File

@ -96,6 +96,25 @@ fn main() {
println!("Success!")
}
//Another solution
fn main() {
let mut v = Vec::from([1, 2, 3,4,5]);
for i in 0..5 {
println!("{:?}", v[i])
}
for i in 0..5 {
v[i] +=1;
}
assert_eq!(v, vec![2, 3, 4, 5, 6]);
println!("Success!")
}
```
5.
@ -215,4 +234,4 @@ fn main() {
ip.display();
}
}
```
```