mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
combine into one filter_map
This commit is contained in:
parent
922ba9ed5c
commit
44bf8f19f1
@ -289,15 +289,14 @@ impl<'a> Widget for Subtitles<'a> {
|
||||
subtitles
|
||||
.subtitles
|
||||
.iter()
|
||||
.filter_map(|(localization, data)| Some((localization, data.last()?)))
|
||||
.filter(|(_, data)| {
|
||||
data.position.map_or(true, |pos| {
|
||||
pos.distance_squared(listener_pos)
|
||||
< MAX_SUBTITLE_DIST * MAX_SUBTITLE_DIST
|
||||
})
|
||||
})
|
||||
.map(|(localization, data)| {
|
||||
(self.localized_strings.get_msg(localization), data)
|
||||
.filter_map(|(localization, data)| {
|
||||
let data = data.last()?;
|
||||
data.position
|
||||
.map_or(true, |pos| {
|
||||
pos.distance_squared(listener_pos)
|
||||
< MAX_SUBTITLE_DIST * MAX_SUBTITLE_DIST
|
||||
})
|
||||
.then(|| (self.localized_strings.get_msg(localization), data))
|
||||
}),
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user