Function http_status_codes2::find_by_substring
source · pub fn find_by_substring<'a>(
needle: &'a str,
registry: &'static [(usize, &'static str, &'static str, &'static str)]
) -> impl Iterator<Item = &'static (usize, &'static str, &'static str, &'static str)> + 'a
Expand description
Search a given registry for a HTTP statuses containing a substring (needle) in their description. Returns an iterator over the results.
Example:
use http_status_codes2::{find_by_substring, status_code_registry::UNOFFICIAL_CODE_REGISTRY};
let mut it = find_by_substring("teapot", &UNOFFICIAL_CODE_REGISTRY);
assert_eq!(
it.next(),
Some((
418,
"I'm a teapot",
"[RFC2324, Section 2.3.2]",
"https://www.rfc-editor.org/rfc/rfc2324.html#section-2.3.2"
))
.as_ref()
);
assert_eq!(it.next(), None);