fn check_param_app_mode<'param, 'file>(
    param: &'param IntroParam<'file>,
    expected_app_mode: &AppMode,
) -> Result<Option<Cow<'param, Pattern<'file>>>, Diagnostic<FileSpan>> {
    match (param, expected_app_mode) {
        (IntroParam::Explicit(pattern), AppMode::Explicit) => Ok(Some(Cow::Borrowed(pattern))),
        (IntroParam::Implicit(_, intro_label, pattern), AppMode::Implicit(ty_label))
        | (IntroParam::Instance(_, intro_label, pattern), AppMode::Instance(ty_label))
            if intro_label.slice == ty_label.0 =>
        {
            match pattern {
                None => Ok(Some(Cow::Owned(Pattern::Var(intro_label.clone())))),
                Some(pattern) => Ok(Some(Cow::Borrowed(pattern))),
            }
        },
        (_, AppMode::Implicit(_)) | (_, AppMode::Instance(_)) => Ok(None),
        (IntroParam::Implicit(span, _, _), AppMode::Explicit)
        | (IntroParam::Instance(span, _, _), AppMode::Explicit) => {
            let message = "unexpected parameter pattern";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(*span).with_message("this parameter is not needed"),
            ))
        },
    }
}
/// Check that a given parameter matches the expected application mode, and
/// return the pattern inside it.
Check that a given parameter matches the expected application mode, and
return the pattern inside it.
Check that a given parameter matches the expected application mode and return the pattern inside it .
fn check_param_app_mode<'param, 'file>(
    param: &'param IntroParam<'file>,
    expected_app_mode: &AppMode,
) -> Result<Option<Cow<'param, Pattern<'file>>>, Diagnostic<FileSpan>> {
    match (param, expected_app_mode) {
        (IntroParam::Explicit(pattern), AppMode::Explicit) => Ok(Some(Cow::Borrowed(pattern))),
        (IntroParam::Implicit(_, intro_label, pattern), AppMode::Implicit(ty_label))
        | (IntroParam::Instance(_, intro_label, pattern), AppMode::Instance(ty_label))
            if intro_label.slice == ty_label.0 =>
        {
            match pattern {
                None => Ok(Some(Cow::Owned(Pattern::Var(intro_label.clone())))),
                Some(pattern) => Ok(Some(Cow::Borrowed(pattern))),
            }
        },
        (_, AppMode::Implicit(_)) | (_, AppMode::Instance(_)) => Ok(None),
        (IntroParam::Implicit(span, _, _), AppMode::Explicit)
        | (IntroParam::Instance(span, _, _), AppMode::Explicit) => {
            let message = "unexpected parameter pattern";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(*span).with_message("this parameter is not needed"),
            ))
        },
    }
}
fn check_param_app_mode < ' param , ' file > ( param : & ' param IntroParam < ' file > , expected_app_mode : & AppMode , ) -> Result < Option < Cow < ' param , Pattern < ' file > > > , Diagnostic < FileSpan > > { match ( param , expected_app_mode ) { ( IntroParam :: Explicit ( pattern ) , AppMode :: Explicit ) => Ok ( Some ( Cow :: Borrowed ( pattern ) ) ) , ( IntroParam :: Implicit ( _ , intro_label , pattern ) , AppMode :: Implicit ( ty_label ) ) | ( IntroParam :: Instance ( _ , intro_label , pattern ) , AppMode :: Instance ( ty_label ) ) if intro_label . slice == ty_label . 0 => { match pattern { None => Ok ( Some ( Cow :: Owned ( Pattern :: Var ( intro_label . clone ( ) ) ) ) ) , Some ( pattern ) => Ok ( Some ( Cow :: Borrowed ( pattern ) ) ) , } } , ( _ , AppMode :: Implicit ( _ ) ) | ( _ , AppMode :: Instance ( _ ) ) => Ok ( None ) , ( IntroParam :: Implicit ( span , _ , _ ) , AppMode :: Explicit ) | ( IntroParam :: Instance ( span , _ , _ ) , AppMode :: Explicit ) => { let message = " " ; Err ( Diagnostic :: new_error ( message ) . with_label ( DiagnosticLabel :: new_primary ( * span ) . with_message ( " " ) , ) ) } , } }
Check that a given parameter matches the expected application mode, and
return the pattern inside it.
Check that a given parameter matches the expected application mode and return the pattern inside it .
param
&'param IntroParam<'file>
expected_app_mode
&AppMode