fn optionally_check_if_parsed_is_allowed_capture<'a, F: 'a>(
    f: F,
    allowed_captures: &Option<Vec<String>>,
) -> impl Fn(&'a str) -> IResult<&'a str, String, (&'a str, ErrorKind)>
// Result<&'a str, nom::Err<(&'a str, ErrorKind)>>
where
    F: Fn(&'a str) -> IResult<&'a str, String, (&'a str, ErrorKind)>,
{
    let am = allowed_captures.clone(); // I hate how this has to clone in order to work.
    map(
        verify(f, move |s: &String| {
            if let Some(am) = &am {
                am.iter().map(String::as_str).any(|x| x == s)
            } else {
                true
            }
        }),
        |o| o.to_string(),
    )
}
/// If the allowed matches is Some, then check to see if any of the elements in it are what was
/// captured. It will fail if the captured value was not in the provided list.
///
/// If none, it will allow the capture as intended.
If the allowed matches is Some, then check to see if any of the elements in it are what was
captured. It will fail if the captured value was not in the provided list.

If none, it will allow the capture as intended.
If the allowed matches is Some then check to see if any of the elements in it are what was captured . It will fail if the captured value was not in the provided list . If none it will allow the capture as intended .
fn optionally_check_if_parsed_is_allowed_capture<'a, F: 'a>(
    f: F,
    allowed_captures: &Option<Vec<String>>,
) -> impl Fn(&'a str) -> IResult<&'a str, String, (&'a str, ErrorKind)>
// Result<&'a str, nom::Err<(&'a str, ErrorKind)>>
where
    F: Fn(&'a str) -> IResult<&'a str, String, (&'a str, ErrorKind)>,
{
    let am = allowed_captures.clone(); // I hate how this has to clone in order to work.
    map(
        verify(f, move |s: &String| {
            if let Some(am) = &am {
                am.iter().map(String::as_str).any(|x| x == s)
            } else {
                true
            }
        }),
        |o| o.to_string(),
    )
}
fn optionally_check_if_parsed_is_allowed_capture < ' a , F : ' a > ( f : F , allowed_captures : & Option < Vec < String > > , ) -> impl Fn ( & ' a str ) -> IResult < & ' a str , String , ( & ' a str , ErrorKind ) > // Result<&'a str, nom::Err<(&'a str, ErrorKind)>> where F : Fn ( & ' a str ) -> IResult < & ' a str , String , ( & ' a str , ErrorKind ) > , { let am = allowed_captures . clone ( ) ; // I hate how this has to clone in order to work. map ( verify ( f , move | s : & String | { if let Some ( am ) = & am { am . iter ( ) . map ( String :: as_str ) . any ( | x | x == s ) } else { true } } ) , | o | o . to_string ( ) , ) }
If the allowed matches is Some, then check to see if any of the elements in it are what was
captured.
If the allowed matches is Some then check to see if any of the elements in it are what was captured .
f
F
allowed_captures
&Option<Vec<String>>
f
F
allowed_captures
&Option<Vec<String>>