Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let mut v = vec![1, 2, 3];
- // Try to modify vec in-place
- square_each(& v);
- println!("{}", v[1]);
- }
- fn square_each(v: & Vec<i32>) {
- for e in v.iter_mut() {
- *e = (*e) * (*e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement