Fmt Allman style
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
pub module enum_test;
|
||||
|
||||
enum OptionInt {
|
||||
enum OptionInt
|
||||
{
|
||||
None,
|
||||
Some(i32),
|
||||
}
|
||||
|
||||
pub void test_enum_named() {
|
||||
pub void test_enum_named()
|
||||
{
|
||||
let x = OptionInt::None;
|
||||
match x {
|
||||
OptionInt::None => {
|
||||
@@ -17,7 +19,8 @@ pub void test_enum_named() {
|
||||
}
|
||||
}
|
||||
|
||||
pub void test_enum_tuple() {
|
||||
pub void test_enum_tuple()
|
||||
{
|
||||
let x = OptionInt::Some(42);
|
||||
match x {
|
||||
OptionInt::None => {
|
||||
@@ -29,13 +32,17 @@ pub void test_enum_tuple() {
|
||||
}
|
||||
}
|
||||
|
||||
enum Shape {
|
||||
enum Shape
|
||||
{
|
||||
Circle {i32 radius},
|
||||
Rect {i32 w, i32 h},
|
||||
}
|
||||
|
||||
pub void test_enum_struct() {
|
||||
let c = Shape::Circle{radius: 5, };
|
||||
pub void test_enum_struct()
|
||||
{
|
||||
let c = Shape::Circle {
|
||||
radius: 5,
|
||||
};
|
||||
match c {
|
||||
Shape::Circle {radius} => {
|
||||
assert_eq!(radius, 5);
|
||||
@@ -44,7 +51,10 @@ pub void test_enum_struct() {
|
||||
assert_eq!(0, 1);
|
||||
}
|
||||
}
|
||||
let r = Shape::Rect{w: 3, h: 4, };
|
||||
let r = Shape::Rect {
|
||||
w: 3,
|
||||
h: 4,
|
||||
};
|
||||
match r {
|
||||
Shape::Circle {..} => {
|
||||
assert_eq!(0, 1);
|
||||
@@ -55,13 +65,15 @@ pub void test_enum_struct() {
|
||||
}
|
||||
}
|
||||
|
||||
enum Color {
|
||||
enum Color
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
}
|
||||
|
||||
pub void test_enum_eq() {
|
||||
pub void test_enum_eq()
|
||||
{
|
||||
let c = Color::Red;
|
||||
match c {
|
||||
Color::Red => {
|
||||
@@ -73,7 +85,8 @@ pub void test_enum_eq() {
|
||||
}
|
||||
}
|
||||
|
||||
pub void run_tests() {
|
||||
pub void run_tests()
|
||||
{
|
||||
test_enum_named();
|
||||
test_enum_tuple();
|
||||
test_enum_struct();
|
||||
|
||||
Reference in New Issue
Block a user