Merged
Conversation
Owner
ia7ck
commented
Feb 7, 2026
- max_steps = 0 で使うことはなさそう
- get()
Contributor
There was a problem hiding this comment.
Pull request overview
libs/doubling の Doubling に、内部のダブリングテーブル(2^k 遷移)へ直接アクセスする get() を追加し、max_steps == 0 の取り扱いを明確化(現在は拒否)するPRです。
Changes:
Doubling::new()でmax_steps > 0をassert!で強制Doubling::get(start, k)を追加して 2^k 遷移を参照で返却- プロパティテストの入力範囲を
max_steps >= 1に変更し、新しい前提条件に合わせる
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+80
to
83
| assert!(max_steps > 0); | ||
|
|
||
| let log2_max_steps = max_steps.ilog2() as usize; | ||
|
|
There was a problem hiding this comment.
Doubling::new previously supported max_steps == 0 (and fold(start, 0, ...) still works), but this change introduces an unconditional panic for that input. If this crate is consumed externally, this is an API-breaking behavior change; consider keeping the old handling (treat 0 as a valid value) or documenting the new precondition clearly (e.g., in rustdoc / changelog) and making tests reflect the intended contract.
Suggested change
| assert!(max_steps > 0); | |
| let log2_max_steps = max_steps.ilog2() as usize; | |
| let log2_max_steps = if max_steps == 0 { | |
| 0 | |
| } else { | |
| max_steps.ilog2() as usize | |
| }; |
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.