Array As A Parameter Rust

[Solved] Array As A Parameter Rust | Rust - Code Explorer | yomemimo.com
Question : array as a parameter rust

Answered by : jimmy-hypi

fn change_value(arr: &mut [i32]) { arr[1] = 10;
}
fn main() { let mut arr: [i32; 4] = [1, 2, 3, 4]; change_value(&mut arr); println!("this is {}", arr[1]);
}

Source : https://stackoverflow.com/questions/24831828/how-do-i-pass-an-array-to-a-function-in-rust-and-change-its-content | Last Update : Mon, 23 Mar 20

Answers related to array as a parameter rust

Code Explorer Popular Question For Rust