mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed suppressed clippy warnings for #587 - redundant_closure
This commit is contained in:
parent
7459a1e95a
commit
4d6c553b1b
@ -139,7 +139,6 @@ pub fn loadout_remove(equip_slot: EquipSlot, loadout: &mut Loadout) -> Option<it
|
||||
loadout_replace(equip_slot, None, loadout)
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
fn swap_inventory_loadout(
|
||||
inventory_slot: usize,
|
||||
equip_slot: EquipSlot,
|
||||
@ -157,9 +156,7 @@ fn swap_inventory_loadout(
|
||||
let from_inv = if let Some(item) = from_equip {
|
||||
// If this fails and we get item back as an err it will just be put back in the
|
||||
// loadout
|
||||
inventory
|
||||
.insert(inventory_slot, item)
|
||||
.unwrap_or_else(|i| Some(i))
|
||||
inventory.insert(inventory_slot, item).unwrap_or_else(Some)
|
||||
} else {
|
||||
inventory.remove(inventory_slot)
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ type CharacterListResult = Result<Vec<CharacterItem>, Error>;
|
||||
///
|
||||
/// After first logging in, and after a character is selected, we fetch this
|
||||
/// data for the purpose of inserting their persisted data for the entity.
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
pub fn load_character_data(
|
||||
character_id: i32,
|
||||
db_dir: &str,
|
||||
@ -63,7 +63,7 @@ pub fn load_character_data(
|
||||
|
||||
comp::Inventory::default()
|
||||
},
|
||||
|inv| comp::Inventory::from(inv),
|
||||
comp::Inventory::from,
|
||||
),
|
||||
maybe_loadout.map_or_else(
|
||||
|| {
|
||||
@ -102,7 +102,7 @@ pub fn load_character_data(
|
||||
/// In the event that a join fails, for a character (i.e. they lack an entry for
|
||||
/// stats, body, etc...) the character is skipped, and no entry will be
|
||||
/// returned.
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
pub fn load_character_list(player_uuid: &str, db_dir: &str) -> CharacterListResult {
|
||||
let data = schema::character::dsl::character
|
||||
.filter(schema::character::player_uuid.eq(player_uuid))
|
||||
@ -127,7 +127,7 @@ pub fn load_character_list(player_uuid: &str, db_dir: &str) -> CharacterListResu
|
||||
))
|
||||
.build()
|
||||
},
|
||||
|data| comp::Loadout::from(data),
|
||||
comp::Loadout::from,
|
||||
);
|
||||
|
||||
CharacterItem {
|
||||
|
@ -44,7 +44,6 @@ impl<'a> System<'a> for Sys {
|
||||
ReadTrackers<'a>,
|
||||
);
|
||||
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
fn run(
|
||||
&mut self,
|
||||
(
|
||||
@ -163,7 +162,7 @@ impl<'a> System<'a> for Sys {
|
||||
region.entities(),
|
||||
deleted_entities
|
||||
.take_deleted_in_region(key)
|
||||
.unwrap_or_else(|| Vec::new()),
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
let entity_sync_msg = ServerMsg::EntitySync(entity_sync_package);
|
||||
let comp_sync_msg = ServerMsg::CompSync(comp_sync_package);
|
||||
|
@ -39,7 +39,6 @@ pub struct CombatEventMapper {
|
||||
}
|
||||
|
||||
impl EventMapper for CombatEventMapper {
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
fn maintain(&mut self, state: &State, player_entity: EcsEntity, triggers: &SfxTriggers) {
|
||||
let ecs = state.ecs();
|
||||
|
||||
@ -63,10 +62,7 @@ impl EventMapper for CombatEventMapper {
|
||||
})
|
||||
{
|
||||
if let Some(character) = character {
|
||||
let state = self
|
||||
.event_history
|
||||
.entry(entity)
|
||||
.or_insert_with(|| PreviousEntityState::default());
|
||||
let state = self.event_history.entry(entity).or_default();
|
||||
|
||||
let mapped_event = Self::map_event(character, state, loadout);
|
||||
|
||||
|
@ -36,7 +36,6 @@ pub struct MovementEventMapper {
|
||||
}
|
||||
|
||||
impl EventMapper for MovementEventMapper {
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
fn maintain(&mut self, state: &State, player_entity: EcsEntity, triggers: &SfxTriggers) {
|
||||
let ecs = state.ecs();
|
||||
|
||||
@ -62,10 +61,7 @@ impl EventMapper for MovementEventMapper {
|
||||
})
|
||||
{
|
||||
if let Some(character) = character {
|
||||
let state = self
|
||||
.event_history
|
||||
.entry(entity)
|
||||
.or_insert_with(|| PreviousEntityState::default());
|
||||
let state = self.event_history.entry(entity).or_default();
|
||||
|
||||
let mapped_event = match body {
|
||||
Body::Humanoid(_) => Self::map_movement_event(character, physics, state, vel.0),
|
||||
|
@ -162,7 +162,6 @@ pub struct MainMenuUi {
|
||||
}
|
||||
|
||||
impl MainMenuUi {
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn new(global_state: &mut GlobalState) -> Self {
|
||||
let window = &mut global_state.window;
|
||||
let networking = &global_state.settings.networking;
|
||||
@ -216,7 +215,8 @@ impl MainMenuUi {
|
||||
server_address: networking
|
||||
.servers
|
||||
.get(networking.default_server)
|
||||
.map_or_else(|| String::new(), |address| address.clone()),
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
popup: None,
|
||||
connecting: None,
|
||||
show_servers: false,
|
||||
|
@ -211,7 +211,7 @@ impl<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug>
|
||||
#[allow(clippy::needless_range_loop)] // TODO: Pending review in #587
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
#[allow(clippy::panic_params)] // TODO: Pending review in #587
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
fn generate_mesh(
|
||||
&'a self,
|
||||
range: Self::Supplement,
|
||||
@ -343,7 +343,7 @@ impl<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug>
|
||||
maybe_block
|
||||
.filter(|vox| vox.is_opaque() && (!neighbour || vox.is_blended()))
|
||||
.and_then(|vox| vox.get_color())
|
||||
.map(|col| Rgba::from_opaque(col))
|
||||
.map(Rgba::from_opaque)
|
||||
.unwrap_or(Rgba::zero())
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,7 @@ impl<T: Copy + gfx::traits::Pod> Consts<T> {
|
||||
}
|
||||
|
||||
/// Update the GPU-side value represented by this constant handle.
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
pub fn update(
|
||||
&mut self,
|
||||
encoder: &mut gfx::Encoder<gfx_backend::Resources, gfx_backend::CommandBuffer>,
|
||||
@ -26,6 +26,6 @@ impl<T: Copy + gfx::traits::Pod> Consts<T> {
|
||||
) -> Result<(), RenderError> {
|
||||
encoder
|
||||
.update_buffer(&self.buf, vals, 0)
|
||||
.map_err(|err| RenderError::UpdateError(err))
|
||||
.map_err(RenderError::UpdateError)
|
||||
}
|
||||
}
|
||||
|
@ -12,18 +12,16 @@ pub struct Instances<T: Copy + gfx::traits::Pod> {
|
||||
}
|
||||
|
||||
impl<T: Copy + gfx::traits::Pod> Instances<T> {
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn new(factory: &mut gfx_backend::Factory, len: usize) -> Result<Self, RenderError> {
|
||||
Ok(Self {
|
||||
ibuf: factory
|
||||
.create_buffer(len, Role::Vertex, Usage::Dynamic, Bind::TRANSFER_DST)
|
||||
.map_err(|err| RenderError::BufferCreationError(err))?,
|
||||
.map_err(RenderError::BufferCreationError)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn count(&self) -> usize { self.ibuf.len() }
|
||||
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn update(
|
||||
&mut self,
|
||||
encoder: &mut gfx::Encoder<gfx_backend::Resources, gfx_backend::CommandBuffer>,
|
||||
@ -31,6 +29,6 @@ impl<T: Copy + gfx::traits::Pod> Instances<T> {
|
||||
) -> Result<(), RenderError> {
|
||||
encoder
|
||||
.update_buffer(&self.ibuf, instances, 0)
|
||||
.map_err(|err| RenderError::UpdateError(err))
|
||||
.map_err(RenderError::UpdateError)
|
||||
}
|
||||
}
|
||||
|
@ -30,12 +30,11 @@ pub struct DynamicModel<P: Pipeline> {
|
||||
}
|
||||
|
||||
impl<P: Pipeline> DynamicModel<P> {
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn new(factory: &mut gfx_backend::Factory, size: usize) -> Result<Self, RenderError> {
|
||||
Ok(Self {
|
||||
vbuf: factory
|
||||
.create_buffer(size, Role::Vertex, Usage::Dynamic, Bind::empty())
|
||||
.map_err(|err| RenderError::BufferCreationError(err))?,
|
||||
.map_err(RenderError::BufferCreationError)?,
|
||||
})
|
||||
}
|
||||
|
||||
@ -48,7 +47,6 @@ impl<P: Pipeline> DynamicModel<P> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn update(
|
||||
&self,
|
||||
encoder: &mut gfx::Encoder<gfx_backend::Resources, gfx_backend::CommandBuffer>,
|
||||
@ -57,6 +55,6 @@ impl<P: Pipeline> DynamicModel<P> {
|
||||
) -> Result<(), RenderError> {
|
||||
encoder
|
||||
.update_buffer(&self.vbuf, mesh.vertices(), offset)
|
||||
.map_err(|err| RenderError::UpdateError(err))
|
||||
.map_err(RenderError::UpdateError)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ where
|
||||
F::Channel: gfx::format::TextureChannel,
|
||||
<F::Surface as gfx::format::SurfaceTyped>::DataType: Copy,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn new(
|
||||
factory: &mut gfx_backend::Factory,
|
||||
image: &DynamicImage,
|
||||
@ -43,7 +42,7 @@ where
|
||||
gfx::texture::Mipmap::Provided,
|
||||
&[&image.raw_pixels()],
|
||||
)
|
||||
.map_err(|err| RenderError::CombinedError(err))?;
|
||||
.map_err(RenderError::CombinedError)?;
|
||||
|
||||
Ok(Self {
|
||||
tex,
|
||||
@ -89,7 +88,7 @@ where
|
||||
|
||||
/// Update a texture with the given data (used for updating the glyph cache
|
||||
/// texture).
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
pub fn update(
|
||||
&self,
|
||||
encoder: &mut gfx::Encoder<gfx_backend::Resources, gfx_backend::CommandBuffer>,
|
||||
@ -111,7 +110,7 @@ where
|
||||
.update_texture::<<F as gfx::format::Formatted>::Surface, F>(
|
||||
&self.tex, None, info, data,
|
||||
)
|
||||
.map_err(|err| RenderError::TexUpdateError(err))
|
||||
.map_err(RenderError::TexUpdateError)
|
||||
}
|
||||
|
||||
/// Get dimensions of the represented image.
|
||||
|
@ -248,7 +248,7 @@ fn sprite_config_for(kind: BlockKind) -> Option<SpriteConfig> {
|
||||
|
||||
/// Function executed by worker threads dedicated to chunk meshing.
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug>(
|
||||
pos: Vec2<i32>,
|
||||
z_bounds: (f32, f32),
|
||||
@ -292,7 +292,7 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug>(
|
||||
|
||||
instances
|
||||
.entry((block.kind(), seed as usize % cfg.variations))
|
||||
.or_insert_with(|| Vec::new())
|
||||
.or_insert_with(Vec::new)
|
||||
.push(instance);
|
||||
}
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ pub struct Settings {
|
||||
|
||||
impl Default for Settings {
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
fn default() -> Self {
|
||||
let user_dirs = UserDirs::new().expect("System's $HOME directory path not found!");
|
||||
|
||||
@ -690,7 +690,7 @@ impl Default for Settings {
|
||||
.or(user_dirs.picture_dir().map(|dir| dir.join("veloren")))
|
||||
.or(std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|dir| dir.parent().map(|val| PathBuf::from(val))))
|
||||
.and_then(|dir| dir.parent().map(PathBuf::from)))
|
||||
.expect("Couldn't choose a place to store the screenshots");
|
||||
|
||||
Settings {
|
||||
|
@ -4,7 +4,6 @@ use vek::*;
|
||||
#[derive(Clone)]
|
||||
pub struct Event(pub Input);
|
||||
impl Event {
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
pub fn try_from(
|
||||
event: glutin::Event,
|
||||
window: &glutin::ContextWrapper<glutin::PossiblyCurrent, winit::Window>,
|
||||
@ -23,7 +22,7 @@ impl Event {
|
||||
|
||||
fn hidpi_factor(&self) -> f32 { winit::Window::get_hidpi_factor(&self.0) as _ }
|
||||
}
|
||||
convert_event!(event, &WindowRef(window.window())).map(|input| Self(input))
|
||||
convert_event!(event, &WindowRef(window.window())).map(Self)
|
||||
}
|
||||
|
||||
pub fn is_keyboard_or_mouse(&self) -> bool {
|
||||
|
@ -305,7 +305,7 @@ pub struct WorldSim {
|
||||
impl WorldSim {
|
||||
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
|
||||
#[allow(clippy::let_and_return)] // TODO: Pending review in #587
|
||||
#[allow(clippy::redundant_closure)] // TODO: Pending review in #587
|
||||
|
||||
pub fn generate(seed: u32, opts: WorldOpts) -> Self {
|
||||
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
||||
// NOTE: Change 1.0 to 4.0, while multiplying grid_size by 4, for a 4x
|
||||
@ -976,22 +976,22 @@ impl WorldSim {
|
||||
// varying conditions
|
||||
&rock_strength_nz,
|
||||
// initial conditions
|
||||
|posi| alt_func(posi),
|
||||
alt_func,
|
||||
|posi| alt_func(posi) - if is_ocean_fn(posi) { 0.0 } else { 0.0 },
|
||||
is_ocean_fn,
|
||||
// empirical constants
|
||||
uplift_fn,
|
||||
|posi| n_func(posi),
|
||||
|posi| theta_func(posi),
|
||||
|posi| kf_func(posi),
|
||||
|posi| kd_func(posi),
|
||||
|posi| g_func(posi),
|
||||
|posi| epsilon_0_func(posi),
|
||||
|posi| alpha_func(posi),
|
||||
n_func,
|
||||
theta_func,
|
||||
kf_func,
|
||||
kd_func,
|
||||
g_func,
|
||||
epsilon_0_func,
|
||||
alpha_func,
|
||||
// scaling factors
|
||||
|n| height_scale(n),
|
||||
height_scale,
|
||||
k_d_scale(n_approx),
|
||||
|q| k_da_scale(q),
|
||||
k_da_scale,
|
||||
);
|
||||
|
||||
// Quick "small scale" erosion cycle in order to lower extreme angles.
|
||||
@ -1004,16 +1004,16 @@ impl WorldSim {
|
||||
|posi| basement[posi] as f32,
|
||||
is_ocean_fn,
|
||||
|posi| uplift_fn(posi) * (1.0 / max_erosion_per_delta_t),
|
||||
|posi| n_func(posi),
|
||||
|posi| theta_func(posi),
|
||||
|posi| kf_func(posi),
|
||||
|posi| kd_func(posi),
|
||||
|posi| g_func(posi),
|
||||
|posi| epsilon_0_func(posi),
|
||||
|posi| alpha_func(posi),
|
||||
|n| height_scale(n),
|
||||
n_func,
|
||||
theta_func,
|
||||
kf_func,
|
||||
kd_func,
|
||||
g_func,
|
||||
epsilon_0_func,
|
||||
alpha_func,
|
||||
height_scale,
|
||||
k_d_scale(n_approx),
|
||||
|q| k_da_scale(q),
|
||||
k_da_scale,
|
||||
)
|
||||
};
|
||||
|
||||
@ -1071,16 +1071,16 @@ impl WorldSim {
|
||||
|posi| basement[posi] as f32,
|
||||
is_ocean_fn,
|
||||
|posi| uplift_fn(posi) * (1.0 / max_erosion_per_delta_t),
|
||||
|posi| n_func(posi),
|
||||
|posi| theta_func(posi),
|
||||
|posi| kf_func(posi),
|
||||
|posi| kd_func(posi),
|
||||
|posi| g_func(posi),
|
||||
|posi| epsilon_0_func(posi),
|
||||
|posi| alpha_func(posi),
|
||||
|n| height_scale(n),
|
||||
n_func,
|
||||
theta_func,
|
||||
kf_func,
|
||||
kd_func,
|
||||
g_func,
|
||||
epsilon_0_func,
|
||||
alpha_func,
|
||||
height_scale,
|
||||
k_d_scale(n_approx),
|
||||
|q| k_da_scale(q),
|
||||
k_da_scale,
|
||||
)
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user