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"
}
}
建议#
Add ..
if you want to omit the other fields, or use them.
///|
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"
}
}