mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix clippy lints
This commit is contained in:
parent
850eb1c293
commit
ce9d706ed4
@ -92,7 +92,7 @@ impl<T: Compound> AssetExt for T {
|
|||||||
pub struct Image(pub Arc<DynamicImage>);
|
pub struct Image(pub Arc<DynamicImage>);
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
pub fn to_image(&self) -> Arc<DynamicImage> { self.0.clone() }
|
pub fn to_image(&self) -> Arc<DynamicImage> { Arc::clone(&self.0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ImageLoader;
|
pub struct ImageLoader;
|
||||||
|
@ -198,6 +198,9 @@ impl assets::Asset for RawItemDef {
|
|||||||
const EXTENSION: &'static str = "ron";
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct OperationFailure;
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
// TODO: consider alternatives such as default abilities that can be added to a
|
// TODO: consider alternatives such as default abilities that can be added to a
|
||||||
// loadout when no weapon is present
|
// loadout when no weapon is present
|
||||||
@ -275,30 +278,30 @@ impl Item {
|
|||||||
/// up by another player.
|
/// up by another player.
|
||||||
pub fn put_in_world(&mut self) { self.reset_item_id() }
|
pub fn put_in_world(&mut self) { self.reset_item_id() }
|
||||||
|
|
||||||
pub fn increase_amount(&mut self, increase_by: u32) -> Result<(), ()> {
|
pub fn increase_amount(&mut self, increase_by: u32) -> Result<(), OperationFailure> {
|
||||||
let amount = u32::from(self.amount);
|
let amount = u32::from(self.amount);
|
||||||
self.amount = amount
|
self.amount = amount
|
||||||
.checked_add(increase_by)
|
.checked_add(increase_by)
|
||||||
.and_then(NonZeroU32::new)
|
.and_then(NonZeroU32::new)
|
||||||
.ok_or(())?;
|
.ok_or(OperationFailure)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decrease_amount(&mut self, decrease_by: u32) -> Result<(), ()> {
|
pub fn decrease_amount(&mut self, decrease_by: u32) -> Result<(), OperationFailure> {
|
||||||
let amount = u32::from(self.amount);
|
let amount = u32::from(self.amount);
|
||||||
self.amount = amount
|
self.amount = amount
|
||||||
.checked_sub(decrease_by)
|
.checked_sub(decrease_by)
|
||||||
.and_then(NonZeroU32::new)
|
.and_then(NonZeroU32::new)
|
||||||
.ok_or(())?;
|
.ok_or(OperationFailure)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_amount(&mut self, give_amount: u32) -> Result<(), ()> {
|
pub fn set_amount(&mut self, give_amount: u32) -> Result<(), OperationFailure> {
|
||||||
if give_amount == 1 || self.item_def.is_stackable() {
|
if give_amount == 1 || self.item_def.is_stackable() {
|
||||||
self.amount = NonZeroU32::new(give_amount).ok_or(())?;
|
self.amount = NonZeroU32::new(give_amount).ok_or(OperationFailure)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(OperationFailure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ impl assets::Compound for AbilityMap {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|(kind, set)| {
|
.map(|(kind, set)| {
|
||||||
(
|
(
|
||||||
kind.clone(),
|
*kind,
|
||||||
// expect cannot fail because CharacterAbility always
|
// expect cannot fail because CharacterAbility always
|
||||||
// provides a default value in case of failure
|
// provides a default value in case of failure
|
||||||
set.map_ref(|s| cache.load_expect(&s).cloned()),
|
set.map_ref(|s| cache.load_expect(&s).cloned()),
|
||||||
|
@ -67,6 +67,7 @@ impl RecipeBook {
|
|||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
struct RawRecipeBook(HashMap<String, ((String, u32), Vec<(String, u32)>)>);
|
struct RawRecipeBook(HashMap<String, ((String, u32), Vec<(String, u32)>)>);
|
||||||
|
|
||||||
impl assets::Asset for RawRecipeBook {
|
impl assets::Asset for RawRecipeBook {
|
||||||
|
@ -152,7 +152,7 @@ impl assets::Loader<Localization> for LocalizationLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for value in asked_localization.vector_map.values_mut() {
|
for value in asked_localization.vector_map.values_mut() {
|
||||||
*value = value.into_iter().map(|s| deunicode(s)).collect();
|
*value = value.iter().map(|s| deunicode(s)).collect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asked_localization.metadata.language_name =
|
asked_localization.metadata.language_name =
|
||||||
|
Loading…
Reference in New Issue
Block a user