fix: use checked_mul() to avoid overflow panic

This commit is contained in:
yuankunzhang
2025-08-22 20:09:37 +08:00
parent 7d0c3e4500
commit 8e2816d187
+1 -1
View File
@@ -110,7 +110,7 @@ fn displacement(input: &mut &str) -> ModalResult<Relative> {
Some(match unit.strip_suffix('s').unwrap_or(unit) {
"year" => Relative::Years(multipler),
"month" => Relative::Months(multipler),
"fortnight" => Relative::Days(14 * multipler),
"fortnight" => Relative::Days(multipler.checked_mul(14)?),
"week" => Relative::Days(7 * multipler),
"day" => Relative::Days(multipler),
"hour" => Relative::Hours(multipler),