Skip to content

Code action to rewrite case on equality expression #5920

Description

@GearsDatapacks

Let's say you have some function like this:

pub type StringType {
  Empty
  NonEmpty
}

pub fn classify(string: String) -> StringType {
  case string == "" {
    True -> Empty
    False -> NonEmpty
  }
}

Then you want to add a new variant to StringType:

pub type StringType {
  Empty
  NonEmpty
  Whitespace
}

Now I would like to add some more cases to my case expression, but since I've used == here, I can't easily do that. So it would be nice to have a code action to convert:

case wibble == wobble {
  True -> on_true
  False -> on_false
}

into:

case wibble {
  wobble -> on_true
  _ -> on_false
}

So that you can expand conditions which were once binary into more complex logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions encouraged

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions