Refactor: Implement Display trait and improve code quality#7
Open
Refactor: Implement Display trait and improve code quality#7
Conversation
…ngs=deny The project has `[lints.rust] warnings = "deny"` in Cargo.toml which turns all compiler and clippy warnings into hard errors. This causes build failures on different Rust toolchain versions that may introduce new warnings. Fixes include: - Replace manual strip_prefix/strip_suffix with std methods - Use Display trait instead of inherent to_string() methods - Simplify filter_map/find_map where possible - Remove unnecessary format!/to_string calls - Fix empty lines after doc comments - Use clamp() instead of manual min/max pattern - Replace &Vec<T> with &[T] in function signatures - Use if-let instead of is_some()+unwrap() - Add #[allow] for structural issues (too_many_arguments, type_complexity) Closes #6 https://claude.ai/code/session_01J96NRV6o9dKTmr7igJmcaG
Change module-level and section-header /// doc comments to // regular comments where they don't document a specific item, preventing empty-line-after-doc-comment clippy warnings. Also inline remaining format!() calls in println!() macros. https://claude.ai/code/session_01J96NRV6o9dKTmr7igJmcaG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the codebase to implement Rust's
Displaytrait for better idiomatic string conversion, improves code quality through various clippy suggestions, and makes numerous small improvements to code clarity and maintainability.Key Changes
Display Trait Implementation
to_string()method withstd::fmt::Displayimplementation, removing unnecessary.to_owned()callsto_string()method withDisplaytrait implementationto_string()method withDisplaytrait implementationDefault Trait Improvements
#[derive(Default)]with#[default]attribute instead of manual implementation#[derive(Default)]with#[default]attribute#[derive(Default)]instead of manual implementation#[derive(Default)]instead of manual implementationCode Quality & Idiom Improvements
map_err(|e| function(e))withmap_err(function)for cleaner error handlingstarts_with()checks withstrip_prefix()for more idiomatic string handlingfilter_map()withmap()where filtering logic was unnecessary.min(1.0).max(0.0)with.clamp(0.0, 1.0)for range clampingmap_or(false, ...)withis_ok_and()andis_some_and()for better readabilityvec![...]with array literals[...]where appropriate&format!(...)withformat!(...)where reference wasn't neededformat_args!(...).to_string()with direct string formattingDocumentation & Comments
///) to regular comments (//) for module-level documentation where appropriateMinor Fixes
use chrono;)#[allow(clippy::too_many_arguments)]attributes where needed#[allow(clippy::module_inception)]attribute"\n"with'\n'for single character stringsif letandor_else()chainsImplementation Details
Displaytrait for consistencyhttps://claude.ai/code/session_01J96NRV6o9dKTmr7igJmcaG