refactor: declare each const in the narrowest scope that holds its uses - #393
Merged
Merged
Conversation
Apply the const-scope rule in .claude/rules/rust.md across src/ and crates/. A const that one function names moves into that function, and a const that states a property of one type becomes an associated const. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move every associated const that sat below a method to the top of its impl block, whatever its visibility, and state the ordering in .claude/rules/rust.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
.claude/rules/rust.mdrequires eachconstto live in the narrowest scope that holds its uses, but many constants undersrc/andcrates/were still module-level: some named by a single function, others stating a property of one type.Solution
Apply the rule across
src/andcrates/, with no change in behavior.///.FACTORS/BASEFontZoom::FACTORS/FontZoom::BASEWEBVIEW_TICKUpdatePolicy::WEBVIEW_TICKINITIAL_POOL_CAPImeGlyphPool::INITIAL_CAPMAX_ASSET_LENStaticAsset::MAX_LENDEFAULT_THICKNESSCursorConfig::DEFAULT_THICKNESSDEFAULT_FOREGROUND/DEFAULT_BACKGROUNDPalette::DEFAULT_FOREGROUND/Palette::DEFAULT_BACKGROUNDMAX_TITLE_DEPTHTitleState::MAX_STACK_DEPTHMAX_APC_LENWebviewApcRequest::MAX_LENMAX_INTERMEDIATESCsiParams::MAX_INTERMEDIATESMAX_SUBPARAMSGroup::MAX_SUBPARAMSMAX_INLINE_HTMLValidatedRegistration::MAX_INLINE_HTMLplacement::MAX_ROWS/MAX_COLSPlacementSize::MAX_ROWS/PlacementSize::MAX_COLSgrid::MIN_COLUMNSGridSize::MIN_COLSThe last two rows change
orzma_vt::prelude:MAX_ROWS,MAX_COLSandMIN_COLUMNSare no longer exported, andMIN_COLUMNSis renamed to matchGridSize::MAX_COLS.Doc comments that named a constant which is now function-local describe the behavior instead.
Associated consts are declared above the methods of their
impl, whatever their visibility..claude/rules/rust.mdnow states this, and the consts that sat below a method (Binding::LEADER_TOKEN/REPEAT_TOKEN,PointerButton::ALL,QueueSampler::BACKLOG_FLOOR) move up as well.Left at module level:
orzma_tty'sMAX_CURSOR_KEYS: the type it bounds ispub(crate), and the publicWheelConfigdoc links to it.Constants shared by more than one type (
MAX_PLACEMENTS,MAX_COMBINING), and constants named by one function plus a test or another item's intra-doc link.src/window_icon.rsis Windows-only and was not compiled locally; CI covers it.🤖 Generated with Claude Code