pub(crate) fn try_consume_first_match<T: Copy>(
    s: &mut &str,
    opts: impl IntoIterator<Item = (impl AsRef<str>, T)>,
) -> Option<T> {
    opts.into_iter().find_map(|(expected, value)| {
        if s.starts_with(expected.as_ref()) {
            *s = &s[expected.as_ref().len()..];
            Some(value)
        } else {
            None
        }
    })
}
/// Attempt to find one of the strings provided, returning the first value.
Attempt to find one of the strings provided, returning the first value.
Attempt to find one of the strings provided returning the first value .
pub(crate) fn try_consume_first_match<T: Copy>(
    s: &mut &str,
    opts: impl IntoIterator<Item = (impl AsRef<str>, T)>,
) -> Option<T> {
    opts.into_iter().find_map(|(expected, value)| {
        if s.starts_with(expected.as_ref()) {
            *s = &s[expected.as_ref().len()..];
            Some(value)
        } else {
            None
        }
    })
}
pub ( crate ) fn try_consume_first_match < T : Copy > ( s : & mut & str , opts : impl IntoIterator < Item = ( impl AsRef < str > , T ) > , ) -> Option < T > { opts . into_iter ( ) . find_map ( | ( expected , value ) | { if s . starts_with ( expected . as_ref ( ) ) { * s = & s [ expected . as_ref ( ) . len ( ) .. ] ; Some ( value ) } else { None } } ) }
Attempt to find one of the strings provided, returning the first value.
Attempt to find one of the strings provided returning the first value .
s
&mut &str
opts
impl IntoIterator<Item = (impl AsRef<str>, T)>
s
&mut &str
opts
impl IntoIterator<Item = (impl AsRef<str>, T)>