E4198#
编译器诊断名称:struct_constr_not_implemented。
当 struct 声明构造器签名时,必须将该构造器实现为对应的 Type::new 方法。声明只给出构造器签名,并不会创建实现体。
错误示例#
///|
priv struct Point {
x : Int
fn new(Int) -> Point
}
建议#
定义匹配的 Type::new 方法。
///|
priv struct Point {
x : Int
fn new(Int) -> Point
}
///|
fn Point::new(x : Int) -> Point {
{ x, }
}
///|
test {
let point = Point(4)
inspect(point.x, content="4")
}