Use unwrap_or_else to fix two or_fun_call and suppress one

This commit is contained in:
ice_iix 2020-06-30 19:09:15 -07:00
parent 07fd4788e1
commit 0f9dcd2515
3 changed files with 5 additions and 2 deletions

View File

@ -299,7 +299,8 @@ fn main2() {
let textures = renderer.get_textures();
let dpi_factor = window.window().scale_factor();
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
opt.default_protocol_version.unwrap_or("".to_string()),
opt.default_protocol_version
.unwrap_or_else(|| "".to_string()),
);
let mut game = Game {
server: server::Server::dummy_server(resource_manager.clone()),

View File

@ -891,7 +891,7 @@ impl RawModel {
.texture_vars
.get(&name[1..])
.cloned()
.unwrap_or("".to_owned());
.unwrap_or_else(|| "".to_owned());
return self.lookup_texture(&tex);
}
name.to_owned()

View File

@ -994,6 +994,7 @@ impl World {
self.load_chunk19_or_115(false, x, z, new, mask, data)
}
#[allow(clippy::or_fun_call)]
fn load_chunk19_or_115(
&mut self,
read_biomes: bool,
@ -1068,6 +1069,7 @@ impl World {
mappings
.get(&id)
.cloned()
// TODO: fix or_fun_call, but do not re-borrow self
.unwrap_or(block::Block::by_vanilla_id(
id,
self.protocol_version,