Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
m00nwtchr committed Jul 27, 2024
1 parent 705869e commit a651839
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 58 deletions.
15 changes: 6 additions & 9 deletions src/component/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ where

match event {
Event::IntegrityChanged(val) => character.integrity = val,
Event::IntegrityDamage(wound) => match &mut character.splat {
Splat::Changeling(.., data) => {
data.clarity.poke(&wound);
if let Wound::Lethal = wound {
data.clarity.poke(&Wound::Aggravated);
}
}
_ => {}
},
Event::IntegrityDamage(wound) => if let Splat::Changeling(.., data) = &mut character.splat {
data.clarity.poke(&wound);
if let Wound::Lethal = wound {
data.clarity.poke(&Wound::Aggravated);
}
},
Event::TouchstoneChanged(i, val) => {
if let Some(touchstone) = character.touchstones.get_mut(i) {
*touchstone = val;
Expand Down
16 changes: 8 additions & 8 deletions src/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ mod merits;
mod skills;
mod traits;

pub use attributes::{attribute_bar, AttributeBar};
pub use forms::{forms_component, FormsComponent};
pub use info::{info_bar, InfoBar};
pub use integrity::{integrity_component, IntegrityComponent};
pub use list::{list, List};
pub use merits::{merit_component, MeritComponent};
pub use skills::{skills_component, SkillsComponent};
pub use traits::{traits_component, TraitsComponent};
pub use attributes::attribute_bar;
pub use forms::forms_component;
pub use info::info_bar;
pub use integrity::integrity_component;
pub use list::list;
pub use merits::merit_component;
pub use skills::skills_component;
pub use traits::traits_component;
39 changes: 20 additions & 19 deletions src/i18n.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageRequester, Localizer,
};
use std::{
fmt::{self},
sync::Arc,
};
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
use i18n_embed::WebLanguageRequester;
} else {
use i18n_embed::DesktopLanguageRequester;
}
}

use cfg_if::cfg_if;
use cofd::splat::NameKey;
use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, LanguageRequester, Localizer,
};
use once_cell::sync::{Lazy, OnceCell};
use rust_embed::RustEmbed;

use cofd::splat::NameKey;

#[derive(RustEmbed)]
#[folder = "i18n"] // path to the compiled localization resources
struct Localizations;

pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| fluent_language_loader!());
pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
let loader = fluent_language_loader!();

loader
.load_fallback_language(&Localizations)
.expect("Error while loading fallback language");

loader
});

#[macro_export]
macro_rules! fl {
Expand Down Expand Up @@ -82,20 +83,20 @@ pub fn flt(message_id: &str, attribute: Option<&str>) -> Option<String> {
// }

pub fn setup() -> anyhow::Result<Box<dyn LanguageRequester<'static>>> {
let localizer = DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations);
let localizer_arc: Arc<dyn Localizer> = Arc::new(localizer);
let localizer: Arc<dyn Localizer> =
Arc::new(DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations));

Check warning on line 87 in src/i18n.rs

View workflow job for this annotation

GitHub Actions / clippy

usage of an `Arc` that is not `Send` and `Sync`

warning: usage of an `Arc` that is not `Send` and `Sync` --> src/i18n.rs:87:3 | 87 | Arc::new(DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `Arc<DefaultLocalizer<'_>>` is not `Send` and `Sync` as `DefaultLocalizer<'_>` is neither `Send` nor `Sync` = help: if the `Arc` will not used be across threads replace it with an `Rc` = help: otherwise make `DefaultLocalizer<'_>` `Send` and `Sync` or consider a wrapper type such as `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync = note: `#[warn(clippy::arc_with_non_send_sync)]` on by default

let mut language_requester = Box::new({
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
WebLanguageRequester::new()
i18n_embed::WebLanguageRequester::new()
} else {
DesktopLanguageRequester::new()
i18n_embed::DesktopLanguageRequester::new()
}
}
});

language_requester.add_listener(Arc::downgrade(&localizer_arc));
language_requester.add_listener(Arc::downgrade(&localizer));
language_requester.poll()?;

LANGUAGE_LOADER.set_use_isolating(false);
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ impl PlayerCompanionApp {

self.characters = characters
.into_iter()
.map(|val| {
.inspect(|val| {
val.calc_mod_map();
val
})
.map(|val| Rc::new(RefCell::new(val)))
.collect();
Expand Down
10 changes: 5 additions & 5 deletions src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mod equipment;
mod overview;
mod splat_extras;

pub use character_list::{character_list, CharacterList};
pub use creator::{creator_view, CreatorView};
pub use equipment::{equipment_tab, EquipmentTab};
pub use overview::{overview_tab, OverviewTab};
pub use splat_extras::{splat_extras_tab, SplatExtrasTab};
pub use character_list::character_list;
pub use creator::creator_view;
pub use equipment::equipment_tab;
pub use overview::overview_tab;
pub use splat_extras::splat_extras_tab;
19 changes: 8 additions & 11 deletions src/view/splat_extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,14 @@ where
Some(data.shadow_gifts.len() + 1),
None,
data.shadow_gifts.clone(),
{
let shadow_gifts = shadow_gifts;
move |i, val| {
pick_list(
shadow_gifts.clone(),
val.map(Into::<Translated<ShadowGift>>::into),
move |val| Event::ShadowGiftChanged(i, val.unwrap()),
)
.padding(INPUT_PADDING)
.into()
}
move |i, val| {
pick_list(
shadow_gifts.clone(),
val.map(Into::<Translated<ShadowGift>>::into),
move |val| Event::ShadowGiftChanged(i, val.unwrap()),
)
.padding(INPUT_PADDING)
.into()
},
);

Expand Down
4 changes: 2 additions & 2 deletions src/widget/dots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ where
for (i, layout) in iter(layout, &self.axis).enumerate() {
let bounds = layout.bounds();

if let Some(_) = cursor.position_over(bounds) {
if cursor.position_over(bounds).is_some() {
mouse_i = Some(i);
}
}
Expand Down Expand Up @@ -230,7 +230,7 @@ where
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
| event::Event::Touch(touch::Event::FingerPressed { .. }) => {
for (i, layout) in iter(layout, &self.axis).enumerate() {
if let Some(_) = cursor.position_over(layout.bounds()) {
if cursor.position_over(layout.bounds()).is_some() {
let i = if self.value as usize == i + 1 {
i
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/widget/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use iced::{event, touch, Background, Theme};
use iced::{mouse, Alignment, Border, Color, Element, Length, Rectangle, Size};

use cofd::character::{Damage, Wound};
use iced::border::Radius;

pub struct HealthTrack<'a, Message, Theme>
where
Expand Down Expand Up @@ -148,7 +147,7 @@ where
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
| event::Event::Touch(touch::Event::FingerPressed { .. }) => {
for (i, layout) in layout.children().flat_map(Layout::children).enumerate() {
if let Some(_) = cursor.position_over(layout.bounds()) {
if cursor.position_over(layout.bounds()).is_some() {
let wound = self.damage.get_i(i);
shell.publish((self.on_click)(wound));

Expand Down

0 comments on commit a651839

Please sign in to comment.