Skip to content

intersects

Returns true when a and b share at least one element.

use helpers4::array::intersects;

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 intersects<T: Eq + Hash>(a: &[T], b: &[T]) -> bool
ParameterTypeDescription
a&[T]The first slice.
b&[T]The second slice.

bool

use helpers4::array::intersects;

assert!(intersects(&[1, 2, 3], &[3, 4]));
assert!(!intersects(&[1, 2], &[3, 4]));

src/array/intersects.rs