Skip to content

Pattern support #2082

Open
Open
@goar5670

Description

Exhaustive list of what needs to be supported for patterns.

match:

  • LiteralPattern 1, 'a'
  • IdentifierPattern e
  • WildcardPattern _
  • PathPattern
  • TuplePattern (done for multiple item type, remaining range item type (1, 2, .., 10, 11))
  • StructPattern
  • TupleStructPattern
  • SlicePattern [a, b, _]
  • RangePattern 1..=5
  • ReferencePattern
  • RestPattern ..
  • AltPattern Foo::A | Foo::B

Match to-dos (done items not listed)

if let and while let are not yet implemented but they'll follow the same logic as match.
Once the refactor in #2004 is done, we'll be able to add support for if let and while let.

function params and let statements (refutable patterns omitted):

  • IdentifierPattern e
  • WildcardPattern _
  • PathPattern
  • TuplePattern
  • StructPattern (TUPLE_PAT and IDENT_PAT item types remaining)
  • TupleStructPattern (range items type remaining)
  • SlicePattern [a, b, _]
  • ReferencePattern
  • RestPattern ..
  • AltPattern Foo::A | Foo::B

Params and Vars to-dos:

  • Irrefutability checks.
  • what else?

patterns in for loops cannot be added until #869 is finished.

additional to-dos:

  • identifier pattern binding
  • ref mut identifier pattern handling
  • exhaustiveness/usefulness checks

Anything I forgot?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions