Skip to content

Commit 28b9f11

Browse files
authored
Merge pull request #179 from cakebaker/remove_unnecessary_option
chore: remove unnecessary `Option` as return value
2 parents b68c325 + 6feeddf commit 28b9f11

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/items/time.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub struct Time {
7272
}
7373

7474
impl Offset {
75-
fn merge(self, offset: Offset) -> Option<Offset> {
75+
fn merge(self, offset: Offset) -> Offset {
7676
fn combine(a: u32, neg_a: bool, b: u32, neg_b: bool) -> (u32, bool) {
7777
if neg_a == neg_b {
7878
(a + b, neg_a)
@@ -91,11 +91,11 @@ impl Offset {
9191
let hours = hours_minutes / 60;
9292
let minutes = hours_minutes % 60;
9393

94-
Some(Offset {
94+
Offset {
9595
negative,
9696
hours,
9797
minutes,
98-
})
98+
}
9999
}
100100
}
101101

@@ -322,9 +322,7 @@ fn timezone_name_offset(input: &mut &str) -> ModalResult<Offset> {
322322
// Only process if the input cannot be parsed as a relative time.
323323
if peek(relative::parse).parse_next(input).is_err() {
324324
if let Ok(other_tz) = timezone_num.parse_next(input) {
325-
let newtz = tz
326-
.merge(other_tz)
327-
.ok_or(ErrMode::Cut(ContextError::new()))?;
325+
let newtz = tz.merge(other_tz);
328326

329327
return Ok(newtz);
330328
};

0 commit comments

Comments
 (0)