Guest User

Untitled

a guest
Jan 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. fn countdown_gm_update(x: u32) -> Vec<u32> {
  2. let mut vector = Vec::<u32>::new();
  3. //Still confuse why we need using 'mut v', if we just use v: &mut Vec<u32>
  4. // -> error: cannot borrow `v` as mutable, as it is not declared as mutable
  5. fn aux(x: u32, mut v: &mut Vec<u32>) {
  6. println!("{:p}", v);
  7. if x != 0 {
  8. v.push(x);
  9. aux(x-1, &mut v)
  10. }
  11. }
  12. aux(x, &mut vector);
  13. return vector;
  14. }
  15.  
  16. fn main() {
  17. println!("{:?}", countdown_gm_update(10));
  18. }
Add Comment
Please, Sign In to add comment