Skip to content

Commit 0660b26

Browse files
committed
Simplify PackedOption::map_option
1 parent 7c9b6d7 commit 0660b26

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crates/bevy_utils/src/packed_option.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ impl<T: NoneValue> PackedOption<T> {
107107
/// Maps a `PackedOption<T>` to `Option<U>` by applying a function to the contained value.
108108
#[inline]
109109
pub fn map_option<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
110-
if self.is_some() {
111-
Some(f(self.0))
112-
} else {
113-
None
114-
}
110+
self.is_some().then(|| f(self.0))
115111
}
116112

117113
/// Takes the value out of the packed option, leaveing `None` in its place.

0 commit comments

Comments
 (0)