E0027

E0027#

The syntax is deprecated. Please refer to the warning message on the reason and potential fix.

For example, one of the deprecated usage is using constructors as functions. Instead, partial application should be used to create a function from a constructor.

Erroneous example#

enum Message {
  Add(String)
} derive(Show)

fn perform[T](message : (T) -> Message, produce : () -> T) -> Message {
  message(produce())
}

fn main {
  println(perform(Add, fn() { "Hello, world!" }))
  //              ^^^
  // Warning: Using constructor as function directly is
  // deprecated. Use the partial application syntax instead
}

Suggestion#

Migrate the code according to the warning message. In this case, the code should be changed to use the partial application syntax.

// ...
fn main {
  println(perform(Add(_), fn() { "Hello, world!" }))
}