E0027#
语法已弃用。请参考警告消息,了解原因和潜在修复方法。
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.
错误示例#
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
}
建议#
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!" }))
}