E0056#
Missing field in struct pattern.
The warning is emitted when pattern matching on a struct pattern and having missing fields.
错误示例#
///|
struct Point {
x : Int
y : Int
}
///|
pub fn quadrant(p : Point) -> String {
match p {
{ x: _..<0 } => "Third or Fourth Quadrant"
{ x: 0..<_ } => "First or Second Quadrant"
}
}
建议#
如果要省略其他字段,请添加 ..,或者使用它们。
///|
struct Point {
x : Int
y : Int
}
///|
pub fn quadrant(p : Point) -> String {
match p {
{ x: _..<0, .. } => "Third or Fourth Quadrant"
{ x: 0..<_, y: 0..<_ } => "First Quadrant"
{ x: 0..<_, y: _..<0 } => "Second Quadrant"
}
}