Skip to content

Commit 2d0d101

Browse files
Update main.rs
Fix default value of fraction initialize
1 parent 39b3809 commit 2d0d101

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl Fraction {
138138
fn from(value: String) -> Fraction {
139139
let value = value.split("/").collect::<Vec<&str>>();
140140
let mut fraction = Fraction {
141-
numerator: value.get(0).unwrap_or(&"0").parse::<isize>().unwrap_or(1),
141+
numerator: value.get(0).unwrap_or(&"0").parse::<isize>().unwrap_or(0),
142142
denominator: value.get(1).unwrap_or(&"1").parse::<isize>().unwrap_or(1),
143143
};
144144
fraction.simplify();

0 commit comments

Comments
 (0)