Skip to main content

remove_duplicates

Function remove_duplicates 

Source
pub fn remove_duplicates(list: &[i32]) -> Result<Vec<i32>, String>
Expand description

Remove duplicate elements from an array, preserving order.

Takes a list reference and returns a Vec<i32> or an error explaining the situation.

ยงExamples

Basic usage:

let result = algorithmz::array::remove_duplicates(&[1,1,2,3,3,4,4,5]).unwrap();
assert_eq!(result, [1,2,3,4,5]);

Match example:

use algorithmz::array::remove_duplicates;
match remove_duplicates(&[1,1,2,3,3,4,5,5,9]) {
    Ok(n) => println!("The result was: {:?}",n),
    Err(e) => eprintln!("The error was: {}",e),
}