Skip to content

symmetric_difference

Returns the elements present in exactly one of a and b.

The result is the elements of a missing from b (in a’s order), followed by the elements of b missing from a (in b’s order). Duplicates are kept.

use helpers4::array::symmetric_difference;

Cargo feature array (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features array

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.5", default-features = false, features = ["array"] }
pub fn symmetric_difference<T: Clone + Eq + Hash>(a: &[T], b: &[T]) -> Vec<T>
ParameterTypeDescription
a&[T]The first slice.
b&[T]The second slice.

Vec<T>

use helpers4::array::symmetric_difference;

assert_eq!(symmetric_difference(&[1, 2, 3], &[2, 3, 4]), vec![1, 4]);

src/array/symmetric_difference.rs