Remove borrow-checker appeasing code that's no longer necessary in Rust 2021

This commit is contained in:
Olexorus 2022-03-15 16:49:03 +01:00
parent cf66eccb75
commit 2212c3d70c
3 changed files with 15 additions and 15 deletions

View File

@ -647,19 +647,23 @@ impl Renderer {
);
self.views = views;
// appease borrow check (TODO: remove after Rust 2021)
let device = &self.device;
let queue = &self.queue;
let views = &self.views;
let bloom_params = self
.views
.bloom_tgts
.as_ref()
.map(|tgts| locals::BloomParams {
locals: bloom_sizes.map(|size| {
Self::create_consts_inner(device, queue, &[bloom::Locals::new(size)])
Self::create_consts_inner(&self.device, &self.queue, &[bloom::Locals::new(
size,
)])
}),
src_views: [&views.tgt_color_pp, &tgts[1], &tgts[2], &tgts[3], &tgts[4]],
src_views: [
&self.views.tgt_color_pp,
&tgts[1],
&tgts[2],
&tgts[3],
&tgts[4],
],
final_tgt_view: &tgts[0],
});

View File

@ -181,19 +181,15 @@ impl GraphicCache {
return;
}
// TODO: remove with Rust 2021 edition
let cache_map = &mut self.cache_map;
let textures = &mut self.textures;
// Remove from caches
// Maybe make this more efficient if replace graphic is used more often
cache_map.retain(|&(key_id, _key_dims), details| {
self.cache_map.retain(|&(key_id, _key_dims), details| {
// If the entry does not reference id, or it does but we can successfully
// invalidate, retain the entry; otherwise, discard this entry completely.
key_id != id
|| details
.invalidate()
.map_err(|index| textures.remove(index))
.map_err(|index| self.textures.remove(index))
.is_ok()
});
}

View File

@ -125,13 +125,13 @@ impl ItemTooltipManager {
{
let mp_h = MOUSE_PAD_Y / self.logical_scale_factor;
let tooltip_ids = &mut self.tooltip_ids; // TODO: remove with Rust 2021
let mut id_walker = tooltip_ids.walk();
let mut id_walker = self.tooltip_ids.walk();
let tooltip = |transparency, mouse_pos: [f64; 2], ui: &mut UiCell| {
let mut prev_id = None;
for item in items {
let tooltip_id = id_walker.next(tooltip_ids, &mut ui.widget_id_generator());
let tooltip_id =
id_walker.next(&mut self.tooltip_ids, &mut ui.widget_id_generator());
// Fill in text and the potential image beforehand to get an accurate size for
// spacing
let tooltip = tooltip