Skip to main content

is_type_position

Function is_type_position 

Source
fn is_type_position(line: &str) -> bool
Expand description

The cursor sits in a type position: a return type (-> T), a type annotation/field type (: T), or inside a [ … ] type-argument list. The partial type name being typed is stripped before inspecting the preceding token, so : Optio and -> Eff both qualify.

Conservative by construction: a list literal [1, 2 is excluded (its [ is not preceded by a type constructor). The one accepted false positive is a record construction value (Order { id: <cursor>), lexically identical to a record field-type declaration — offering type names there is mild noise.