Removed C style flow control

This commit is contained in:
2026-06-10 04:35:11 +02:00
parent 286894c5db
commit afd3d05e2f
10 changed files with 42 additions and 111 deletions
+5 -5
View File
@@ -5,7 +5,7 @@ enum OptionInt {
pub fn test_enum_named() {
let x = OptionInt::None;
match (x) {
match x {
OptionInt::None => { assert_eq!(1, 1); }
OptionInt::Some[_] => { assert_eq!(0, 1); }
}
@@ -13,7 +13,7 @@ pub fn test_enum_named() {
pub fn test_enum_tuple() {
let x = OptionInt::Some(42);
match (x) {
match x {
OptionInt::None => { assert_eq!(0, 1); }
OptionInt::Some[v] => { assert_eq!(v, 42); }
}
@@ -26,13 +26,13 @@ enum Shape {
pub fn test_enum_struct() {
let c = Shape::Circle { radius: 5 };
match (c) {
match c {
Shape::Circle { radius } => { assert_eq!(radius, 5); }
Shape::Rect { .. } => { assert_eq!(0, 1); }
}
let r = Shape::Rect { w: 3, h: 4 };
match (r) {
match r {
Shape::Circle { .. } => { assert_eq!(0, 1); }
Shape::Rect { w, h } => { assert_eq!(w * h, 12); }
}
@@ -46,7 +46,7 @@ enum Color {
pub fn test_enum_eq() {
let c = Color::Red;
match (c) {
match c {
Color::Red => { assert_eq!(1, 1); }
_ => { assert_eq!(0, 1); }
}