Skip to content

Commit

Permalink
fix clippy warnings (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
PenguinWithATie authored Jan 24, 2025
1 parent 8f279c3 commit 9becbe3
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion apis/src/components/molecules/analysis_and_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn AnalysisAndDownload() -> impl IntoView {
game_state.do_analysis();
};
let correspondence = create_read_slice(game_state.signal, |gs| {
gs.game_response.as_ref().map_or(false, |gr| {
gs.game_response.as_ref().is_some_and(|gr| {
gr.speed == GameSpeed::Correspondence || gr.speed == GameSpeed::Untimed
})
});
Expand Down
2 changes: 1 addition & 1 deletion apis/src/components/molecules/control_buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn ControlButtons() -> impl IntoView {
let not_tournament = create_read_slice(game_state.signal, |gs| {
gs.game_response
.as_ref()
.map_or(false, |gr| gr.tournament.is_none())
.is_some_and(|gr| gr.tournament.is_none())
});
let takeback_allowed = create_read_slice(game_state.signal, |gs| gs.takeback_allowed());
let navigate_to_tournament = move |_| {
Expand Down
2 changes: 1 addition & 1 deletion apis/src/components/molecules/live_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn LiveTimer(side: Signal<Color>) -> impl IntoView {
let in_progress = create_read_slice(game_state.signal, |gs| {
gs.game_response
.as_ref()
.map_or(false, |gr| gr.game_status == GameStatus::InProgress)
.is_some_and(|gr| gr.game_status == GameStatus::InProgress)
});
let timer = expect_context::<TimerSignal>().signal;
let tick_rate = Duration::from_millis(100);
Expand Down
2 changes: 1 addition & 1 deletion apis/src/components/molecules/my_schedules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn MySchedules(
user_id: Signal<Option<Uuid>>,
) -> impl IntoView {
let has_schedules = move || {
user_id().map_or(false, |user_id| {
user_id().is_some_and(|user_id| {
games_hashmap.get().iter().any(|(_game_id, game)| {
game.game_status == GameStatus::NotStarted
&& (game.white_player.uid == user_id || game.black_player.uid == user_id)
Expand Down
6 changes: 2 additions & 4 deletions apis/src/components/molecules/rl_banner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ use leptos::*;
pub fn RlBanner() -> impl IntoView {
view! {
<div class="flex flex-col justify-center items-center p-6 mb-3 text-black rounded-sm bg-orange-twilight xs:p-8 xs:mb-4">
<h1 class="flex items-center mb-4 text-2xl font-bold xs:text-4xl">
King of the Hive
</h1>
<h1 class="flex items-center mb-4 text-2xl font-bold xs:text-4xl">King of the Hive</h1>
<p>
2025 February Season starts soon! Find out more
2025 February Season starts soon! Find out more
<a
href="https://koth.fly.dev/"
rel="external"
Expand Down
2 changes: 1 addition & 1 deletion apis/src/components/molecules/user_with_rating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn UserWithRating(
})
};
let username = move || player().map_or(String::new(), |p| p.username);
let patreon = move || player().map_or(false, |p| p.patreon);
let patreon = move || player().is_some_and(|p| p.patreon);
let rating = move || match (player(), speed()) {
(Some(player), Some(speed)) => {
view! { <Rating rating=player.ratings.get(&speed).expect("Valid rating from speed").clone() /> }
Expand Down
6 changes: 3 additions & 3 deletions apis/src/components/organisms/analysis/atoms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn UndoButton() -> impl IntoView {
let is_disabled = move || {
analysis
.get()
.map_or(true, |analysis| analysis.current_node.is_none())
.is_none_or(|analysis| analysis.current_node.is_none())
};
let undo = move |_| {
analysis.update(|a| {
Expand Down Expand Up @@ -75,8 +75,8 @@ pub fn HistoryButton(
};

let is_disabled = move || {
analysis.get().map_or(true, |analysis| {
analysis.current_node.map_or(true, |n| match cloned_action {
analysis.get().is_none_or(|analysis| {
analysis.current_node.is_none_or(|n| match cloned_action {
HistoryNavigation::Next => n.get_children_ids().is_empty(),
HistoryNavigation::Previous => n.get_parent_id().is_none(),
})
Expand Down
2 changes: 1 addition & 1 deletion apis/src/components/organisms/analysis/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn History(#[prop(optional)] mobile: bool) -> impl IntoView {
let children_ids = node.get_children_ids();
let siblings_ids = tree.get_sibling_ids(&node_id, true).ok()?;
let parent_deg = siblings_ids.len();
let not_first_sibling = siblings_ids.first().map_or(true, |s| *s != node_id);
let not_first_sibling = siblings_ids.first().is_none_or(|s| *s != node_id);
content = if children_ids.len() > 1 {
/* == More than one child ==
gather all children but the first (secondary variations)
Expand Down
2 changes: 1 addition & 1 deletion apis/src/components/organisms/display_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn DisplayTimer(placement: Placement, vertical: bool) -> impl IntoView {
};
let black_id = create_read_slice(game_state.signal, |gs| gs.black_id);
let player_is_black =
create_memo(move |_| user().map_or(false, |user| Some(user.id) == black_id()));
create_memo(move |_| user().is_some_and(|user| Some(user.id) == black_id()));
let side = Signal::derive(move || match (player_is_black(), placement) {
(true, Placement::Top) => Color::White,
(true, Placement::Bottom) => Color::Black,
Expand Down
4 changes: 2 additions & 2 deletions apis/src/components/organisms/reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn Reserve(
let tournament = game_state
.game_response
.as_ref()
.map_or(false, |gr| gr.tournament.is_some());
.is_some_and(|gr| gr.tournament.is_some());
let status = game_state
.game_response
.as_ref()
Expand Down Expand Up @@ -197,7 +197,7 @@ pub fn ReserveContent(player_color: Memo<Color>) -> impl IntoView {
};
let white_and_black = create_read_slice(game_state.signal, |gs| (gs.white_id, gs.black_id));
let show_buttons = move || {
user().map_or(false, |user| {
user().is_some_and(|user| {
let (white_id, black_id) = white_and_black();
Some(user.id) == black_id || Some(user.id) == white_id
})
Expand Down
2 changes: 1 addition & 1 deletion apis/src/pages/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn Play(#[prop(optional)] extend_tw_classes: &'static str) -> impl IntoView
let show_controls =
Signal::derive(move || !controls_signal.hidden.get() || game_state.is_finished()());
let show_board = create_read_slice(game_state.signal, |gs| {
!gs.game_response.as_ref().map_or(false, |gr| {
!gs.game_response.as_ref().is_some_and(|gr| {
gr.game_start == GameStart::Ready
&& matches!(gr.game_status, GameStatus::NotStarted)
&& gr.tournament_game_result == TournamentGameResult::Unknown
Expand Down
30 changes: 15 additions & 15 deletions apis/src/pages/tournament_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,22 @@ pub fn TournamentCreate() -> impl IntoView {
attr:maxlength="2000"
></textarea>

<div class="flex flex-row p-1 gap-1">
<button
on:click=move |_| is_not_preview_desc.update(|b| *b = !*b)
class="mr-4 flex gap-1 justify-center items-center px-4 font-bold text-white rounded bg-button-dawn dark:bg-button-twilight hover:bg-pillbug-teal active:scale-95 disabled:opacity-25 disabled:cursor-not-allowed disabled:hover:bg-transparent"
>
{move || if is_not_preview_desc() { "Preview" } else { "Edit" }}
</button>
<div class="flex flex-row p-1 gap-1">
<button
on:click=move |_| is_not_preview_desc.update(|b| *b = !*b)
class="mr-4 flex gap-1 justify-center items-center px-4 font-bold text-white rounded bg-button-dawn dark:bg-button-twilight hover:bg-pillbug-teal active:scale-95 disabled:opacity-25 disabled:cursor-not-allowed disabled:hover:bg-transparent"
>
{move || if is_not_preview_desc() { "Preview" } else { "Edit" }}
</button>

<a
class="font-bold text-blue-500 hover:underline"
href="https://commonmark.org/help/"
target="_blank"
>
"Markdown Cheat Sheet"
</a>
</div>
<a
class="font-bold text-blue-500 hover:underline"
href="https://commonmark.org/help/"
target="_blank"
>
"Markdown Cheat Sheet"
</a>
</div>
</Show>
</div>
<div class="p-1">
Expand Down
4 changes: 2 additions & 2 deletions apis/src/providers/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ impl Chat {
self.games_public_new_messages
.get()
.get(&game_id)
.map_or(false, |v| *v)
.is_some_and(|v| *v)
|| self
.games_private_new_messages
.get()
.get(&game_id)
.map_or(false, |v| *v)
.is_some_and(|v| *v)
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion apis/src/providers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl ConfigOpts {
let prefers_sound = prefers_sound().unwrap_or_default();

let (prefers_dark, _) = use_cookie::<String, FromToStringCodec>("darkmode");
let prefers_dark = prefers_dark().map_or(false, |v| v == "true");
let prefers_dark = prefers_dark().is_some_and(|v| v == "true");

let mut confirm_mode = HashMap::new();
for speed in GameSpeed::all().iter() {
Expand Down
2 changes: 1 addition & 1 deletion apis/src/websocket/server_handlers/games_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl GamesSearchHandler {
results: game_responses,
batch,
ctx_to_update: self.options.ctx_to_update.clone(),
more_rows: options.batch_size.map_or(false, |b| b == games.len()),
more_rows: options.batch_size == Some(games.len()),
first_batch: options.current_batch.is_none(),
};
Ok(vec![InternalServerMessage {
Expand Down
4 changes: 2 additions & 2 deletions db/src/models/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ impl Game {
}

pub fn last_game_control(&self) -> Option<GameControl> {
if let Some(last) = self.game_control_history.split_terminator(';').last() {
if let Some(gc) = last.split(' ').last() {
if let Some(last) = self.game_control_history.split_terminator(';').next_back() {
if let Some(gc) = last.split(' ').next_back() {
return Some(
GameControl::from_str(gc)
.expect("Could not get GameControl from game_control_history"),
Expand Down
2 changes: 1 addition & 1 deletion engine/src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Hasher {
} else {
panic!("We need an index");
};
self.hashes[revolution as usize] ^= Self::hash(index << 32 | bug_stack.simple() as u64);
self.hashes[revolution as usize] ^= Self::hash((index << 32) | bug_stack.simple() as u64);
}

// This implements wyhash
Expand Down

0 comments on commit 9becbe3

Please sign in to comment.