Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Created November 12, 2017 18:33
Show Gist options
  • Save m3talsmith/c37088f96c4bd962906066fc91cee504 to your computer and use it in GitHub Desktop.
Save m3talsmith/c37088f96c4bd962906066fc91cee504 to your computer and use it in GitHub Desktop.
Attempt to sort numbers in a non-destructive fashion through a function.
fn sort_array(numbers: &[i32]) -> &[i32] {
let mut sorted_numbers = numbers.clone();
sorted_numbers.sort();
sorted_numbers
}
fn main() {
let numbers: [i32; 7] = [7,1,5,2,4,3,6];
let sorted_numbers = find_duplicates(&numbers);
println!("numbers: {:?}", numbers);
println!("sorted_numbers: {:?}", sorted_numbers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment