Removed C style flow control
This commit is contained in:
@@ -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); }
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ pub fn test_nested_fn_calls() {
|
||||
}
|
||||
|
||||
fn factorial(n i32) i32 {
|
||||
if (n <= 1) 1
|
||||
else n * factorial(n - 1)
|
||||
if n <= 1 { 1 }
|
||||
else { n * factorial(n - 1) }
|
||||
}
|
||||
|
||||
pub fn test_recursive_fn() {
|
||||
|
||||
Reference in New Issue
Block a user