Skip to main content

apply_return_pref

Function apply_return_pref 

Source
pub(crate) fn apply_return_pref(
    auto: ReturnHandling,
    pref: ReturnPref,
    pref_span: Option<Span>,
) -> Result<ReturnHandling>
Expand description

Maps a ReturnPref attribute value onto an auto-detected ReturnHandling.

Only the plain IntoR variant has a bare T for prefer= to wrap, so it is the only variant substituted with its pref-specific counterpart (AsListOf/AsExternalPtrOf/AsNativeOf). Every other variant (Unit, RawSexp, ExternalPtr, Option*, Result*) has its own fixed SEXP-shape rule that prefer= cannot compose with — returning a compile error for those is better than silently dropping the attribute (see the BUG4 audit finding: prefer = "list" on an Option<T> return used to be accepted and silently ignored).