Skip to main content

conversion_expectation

Function conversion_expectation 

Source
pub(crate) fn conversion_expectation(ty: &Type, coerced: bool) -> Option<String>
Expand description

The R-facing expectation for a parameter of Rust type ty, for the message of its Rust conversion failure: '<p>' must be <expected>: ... (see RTypeCheck::expectation).

Derived from the same type classification as the R-side checks, including the coerce widening (coerced) and the Missing<T> / Option<T> wrappers, so the two paths describe an argument the same way. A few types without an R-side check still have an R-facing expectation (unchecked_expectation): Either<L, R>, the AsFromStr markers and tuples. None only for an opaque type (a custom TryFromSexp type, or an Either with such an arm): the wrapper then asks the type at run time (rust_conversion_builder::declared_expectation: a derived newtype’s declared expectation, an Either side by side), else reports invalid '<p>' argument: <reason>.