Skip to content

Commit

Permalink
switch from matches to if lets for enum destructuring (FuelLabs#62)
Browse files Browse the repository at this point in the history
* switch from matches to if lets

* fmt
  • Loading branch information
sezna authored Mar 2, 2022
1 parent c3f1b91 commit eead9c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
22 changes: 8 additions & 14 deletions src/option.sw
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,19 @@ impl Option<T> {

/// Returns `true` if the result is [`Some`].
fn is_some(self) -> bool {
match self {
Option::Some(t) => {
true
},
_ => {
false
},
if let Option::Some(t) = self {
true
} else {
false
}
}

/// Returns `true` if the result is [`None`].
fn is_none(self) -> bool {
match self {
Option::Some(t) => {
false
},
_ => {
true
},
if let Option::Some(t) = self {
false
} else {
true
}
}
}
22 changes: 8 additions & 14 deletions src/result.sw
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,19 @@ impl Result<T, E> {

/// Returns `true` if the result is [`Ok`].
fn is_ok(self) -> bool {
match self {
Result::Ok(t) => {
true
},
_ => {
false
},
if let Result::Ok(t) = self {
true
} else {
false
}
}

/// Returns `true` if the result is [`Err`].
fn is_err(self) -> bool {
match self {
Result::Ok(t) => {
false
},
_ => {
true
},
if let Result::Ok(t) = self {
false
} else {
true
}
}
}

0 comments on commit eead9c9

Please sign in to comment.