Skip to main content

let_type_fits

Function let_type_fits 

Source
pub fn let_type_fits(
    declared: &DataType,
    value: &DataType,
    fresh: bool,
    generics: &Generics,
) -> bool
Expand description

Whether a value of type value may be written into a variable whose let declares declared.

A declared variable is read at its declared type without a run-time test, so a dynamic value goes in only through a downcast (as int), the rule a struct field follows, and a union goes in only when every member fits. fresh marks a list or map literal, which nothing else holds yet: it may be widened into a declaration that names any inside it, the way a return may, since no other holder sees what is put into it afterwards.