Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn countdown_gm_update(x: u32) -> Vec<u32> {
- let mut vector = Vec::<u32>::new();
- //Still confuse why we need using 'mut v', if we just use v: &mut Vec<u32>
- // -> error: cannot borrow `v` as mutable, as it is not declared as mutable
- fn aux(x: u32, mut v: &mut Vec<u32>) {
- println!("{:p}", v);
- if x != 0 {
- v.push(x);
- aux(x-1, &mut v)
- }
- }
- aux(x, &mut vector);
- return vector;
- }
- fn main() {
- println!("{:?}", countdown_gm_update(10));
- }
Add Comment
Please, Sign In to add comment