Skip to content

Commit

Permalink
use unwrap_or_default
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Dec 2, 2024
1 parent 1b60786 commit 1541aa6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/sort/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn sort_by_number(
.iter()
.map(|pair| {
let value = if associative { &pair[1] } else { &pair[0] };
(pair.clone(), value.get_number().unwrap_or(0.0))
(pair.clone(), value.get_number().unwrap_or_default())
})
.collect();

Expand Down Expand Up @@ -91,7 +91,10 @@ pub fn sort_by_number_var(
.iter()
.map(|pair| -> ByondResult<_> {
let value = if associative { &pair[1] } else { &pair[0] };
Ok((pair.clone(), value.read_var::<_, f32>(&var).unwrap_or(0.0)))
Ok((
pair.clone(),
value.read_var::<_, f32>(&var).unwrap_or_default(),
))
})
.collect::<ByondResult<_>>()?;

Expand Down

0 comments on commit 1541aa6

Please sign in to comment.