pub fn array_search<T>(needle: &T, haystack: &Vec<T>) -> Option<usize>where
T: PartialEq,
Expand description
Searches the vector for a given value and returns the first corresponding index if successful
§Description
Searches for needle in haystack.
§Examples
Example #1 array_search() example
use phpify::array::array_search;
let array = vec!["blue", "red", "green", "red"];
assert_eq!(array_search(&"green", &array).unwrap(), 2);
assert_eq!(array_search(&"red", &array).unwrap(), 1);