- ROADMAP: all Phase 1 boxes checked, done-notes added - MODERNIZE: serde item marked APPLIED (persistence uses the derives) - ARCHITECTURE: persist module + modal in the component tree, gaps list updated (persistence no longer a gap) - README: header buttons + autosave in 'What works today', tests section describes both specs, playwright command pins the chromium project
5.9 KiB
MODERNIZE.md
A list of dependency reductions and idiom cleanups for the current codebase. Nothing here is applied yet. Review it, then decide which items to do and when (most fit in ROADMAP Phase 0).
Status notes:
- Every "unused" claim below was verified with a grep: 0 references in
src/. - Toolchain decision: stay on nightly (channel = "nightly"). The stable-Rust item is listed for awareness only.
- Dependency decision (2026-08-04):
itertools,thiserror,anyhow,pretty_env_logger,dotenvystay for certain. The rest of section 1 is under consideration. - Applied 2026-08-04:
lazy_static→std::sync::LazyLock(section 2.1). Everything else in this file is still pending.
1. Unused dependencies
None of these are referenced in src/. Decision: itertools, thiserror,
anyhow, pretty_env_logger and dotenvy stay for certain. The rest is
under consideration.
| dependency | note |
|---|---|
itertools |
keep for now (decision). No usage |
seq-macro |
under consideration. No usage |
leptos-use |
under consideration. No usage |
dotenvy |
keep for now (decision). No usage. Never wired into main |
pretty_env_logger |
keep for now (decision). No usage. Logging uses the log macros |
thiserror |
keep for now (decision). No usage. No error types yet |
http |
under consideration. Optional, enabled by no feature. Code uses actix_web::http::StatusCode |
console_log |
under consideration. No usage. Only console_error_panic_hook is called |
anyhow |
keep for now (decision). Only #[macro_use] extern crate anyhow and prelude aliases. The Result alias and bail!/anyhow! are used nowhere |
js-sys |
under consideration. No direct usage. Resolves transitively. Keep the wasm-bindgen =0.2.126 pin: hydrate() uses #[wasm_bindgen(...)] |
2. Replace crates with std or small local code
-
lazy_static→std::sync::LazyLock(stable since 1.80). APPLIED 2026-08-04:src/statics/mod.rsnow usesLazyLock;lazy_staticremoved fromCargo.toml. Reference sketch:use std::sync::LazyLock; static ITEMS_REFS: LazyLock<ItemReferenceMap> = LazyLock::new(|| { let mut map = HashMap::with_capacity(5_000); utils::read_items(include_str!("../../data/items.json"), &mut map); // base.json, foundry.json (twice — duplication bug), magic.json info!("Loaded {} items", map.len()); ItemReferenceMap(map) }); static ITEMS_NAMES: LazyLock<Vec<&'static str>> = LazyLock::new(|| ITEMS_REFS.0.keys().map(String::as_str).collect());Notes:
include_str!needs literal paths, so keep the five explicit calls.- The current
HashMap::from_iter(map.into_iter())roundtrip is a no-op. Wrap the map directly. ITEMS_NAMESchanges fromVec<&'static String>toVec<&'static str>. The matcher accepts both.
-
num-format→ localgroup_thousandshelper insrc/utils/mod.rs. It exists only for theToFormattedStringbound inNumput. Drop the bound and renderf.to_string()grouped. About 6 lines. -
num-traits→ local saturating trait insrc/components/numput.rs. It exists only for theSaturatingAdd/SaturatingSubbounds onNumput. Define a small local trait and impl it foru8,u16,u32,u64,usize.Numputkeeps its generics. -
serde(direct) → remove now, re-add in ROADMAP phase 1. No derives existed at the time;serde_json::Valueworks without namingserdeinCargo.toml. Phase 1 (persistence) re-addedserde = { version = "1", features = ["derive"] }. APPLIED 2026-08-16: persistence is in;serdeis used by every entity derive — keep it.
Result: dropping the under-consideration items takes [dependencies] from
27 entries to about 18. If the five kept deps are dropped later too, it goes
to about 13.
3. Idiomatic cleanups (no dependency changes)
-
Delete
#![feature(type_alias_impl_trait)]insrc/lib.rs:6. It is unused and warns. -
Stay on nightly. The code uses only stable features (let-chains, let-else, edition 2024,
LazyLock). If the toolchain is ever revisited: drop thenightlyfeatures fromleptos/leptos_router, install stable, and run the three checks. The original build breakage was a nightly regression (min_adt_const_paramsre-gating in nightly 1.99); stable does not have that class of failure. -
Prelude (
src/prelude.rs):- Remove the blanket
#![allow(unused_imports)]and#![allow(dead_code)]. They hide real warnings. - Remove the single-letter
logaliases (warn as w, log as l, info as i, ...). They are unused. - Remove the
anyhowre-exports and typealiases. Keeping theanyhowdependency does not force keeping these dead re-exports. - Replace legacy
#[macro_use] extern crate log;insrc/lib.rswithuse log::{info, error};at the two call sites.
- Remove the blanket
-
read_items(src/utils/mod.rs): use theEntryAPI instead ofcontains_key→get_mut().unwrap(). Removes the unwrap and the double lookup. -
Mock data (
src/entities/mock.rs):HashSet::from_iter(vec![...])→HashSet::from([...]). The dateunwraps are fine: the data is static. -
Minor:
adjust_checkeddrops-> ();numput.rsdrops the unusedleptos::{ logging, ... }import.
4. Opinionated (do only on request)
chrono→jiff. Nicer API, actively maintained. Not worth the churn for this model. If kept:chrono'sserdefeature is unused today — trim it now, re-add in phase 1.cargo fmtnormalization. The repo usesfn foo (spacing; it may be deliberate. Ask before running.- Clippy pass over the result.
Verification
After applying items 1-3, run:
cargo check --no-default-features --features hydrate --lib
cargo check --no-default-features --features ssr --bin aex
cargo check --target wasm32-unknown-unknown --no-default-features --features hydrate --lib