@@ -43,12 +43,12 @@ impl BowlingGame {
43
43
44
44
// Handle normal rolls
45
45
if pins == 10 {
46
- let frame = Frame :: new ( pins, None ) ;
46
+ let frame = Frame :: new ( pins, 0 ) ;
47
47
self . frames . push ( frame) ;
48
48
}
49
49
if self . previous_roll . is_some ( ) {
50
50
let roll1 = self . previous_roll . unwrap ( ) ;
51
- let frame = Frame :: new ( roll1, Some ( pins) ) ;
51
+ let frame = Frame :: new ( roll1, pins) ;
52
52
self . frames . push ( frame) ;
53
53
self . previous_roll = None ;
54
54
} else {
@@ -68,7 +68,7 @@ impl BowlingGame {
68
68
total += frame. score ( self . fill_ball1 . unwrap_or ( 0 ) , self . fill_ball2 . unwrap_or ( 0 ) ) ;
69
69
} else {
70
70
let next_roll1 = next_frame. unwrap ( ) . roll1 ;
71
- let next_roll2 = next_frame. unwrap ( ) . roll2 . unwrap ( ) ;
71
+ let next_roll2 = next_frame. unwrap ( ) . roll2 ;
72
72
total += frame. score ( next_roll1, next_roll2) ;
73
73
}
74
74
}
@@ -91,11 +91,11 @@ impl BowlingGame {
91
91
92
92
pub struct Frame {
93
93
pub roll1 : u16 ,
94
- roll2 : Option < u16 >
94
+ pub roll2 : u16
95
95
}
96
96
97
97
impl Frame {
98
- pub fn new ( roll1 : u16 , roll2 : Option < u16 > ) -> Self {
98
+ pub fn new ( roll1 : u16 , roll2 : u16 ) -> Self {
99
99
return Frame {
100
100
roll1 : roll1,
101
101
roll2 : roll2
@@ -119,6 +119,6 @@ impl Frame {
119
119
return self . roll1 != 10 && self . open_frame_score ( ) == 10
120
120
}
121
121
fn open_frame_score ( & self ) -> u16 {
122
- self . roll1 + self . roll2 . unwrap_or ( 0 )
122
+ self . roll1 + self . roll2
123
123
}
124
124
}
0 commit comments