Crates.io | same_elements |
lib.rs | same_elements |
version | 0.1.0 |
source | src |
created_at | 2021-01-05 11:37:57.503459 |
updated_at | 2021-01-05 11:37:57.503459 |
description | Function to test if two collections contain the same values |
homepage | |
repository | https://github.com/scott97/same_elements |
max_upload_size | |
id | 332058 |
size | 20,550 |
Function to test if two collections contain the same values.
Sometimes when creating unit tests, I need to test that two slices contain the same values, but not necessarily in the same order. You can sort the values before testing that the two slices are identical, or alternatively, you can use this crate instead.
use same_elements::*;
let a = [1,2,3,4,5];
let b = [2,4,1,3,5];
assert!(a.same_elements(&b));