Skip to content

Fix code comment inconsistency and add corresponding tests#139

Open
YichiZhang0613 wants to merge 3 commits intoitsjunetime:mainfrom
YichiZhang0613:fix_inconsistency
Open

Fix code comment inconsistency and add corresponding tests#139
YichiZhang0613 wants to merge 3 commits intoitsjunetime:mainfrom
YichiZhang0613:fix_inconsistency

Conversation

@YichiZhang0613
Copy link

@YichiZhang0613 YichiZhang0613 commented Feb 25, 2026

The comment requires that the following conditions should hold: inclusive_min < exclusive_max and inclusive_min <= around <= exclusive_max, so corresponding assertions should be added.

	/// the following must hold or else this is liable to panic or produce nonsense values:
	/// - inclusive_min < exclusive_max
	/// - inclusive_min <= around <= exclusive_max
	#[must_use]
	pub fn new(around: usize, inclusive_min: usize, exclusive_max: NonZeroUsize) -> Self {		
		Self {
			around,
			inclusive_min,
			exclusive_max,
			next_change: 0,
			next_op: PlusOrMinus::Minus
		}
	}

I also add corresponding tests.

@YichiZhang0613 YichiZhang0613 changed the title Add assertions Add assertions to fix inconsistency Mar 8, 2026
@YichiZhang0613 YichiZhang0613 changed the title Add assertions to fix inconsistency Fix code comment inconsistency Mar 8, 2026
@YichiZhang0613 YichiZhang0613 changed the title Fix code comment inconsistency Fix code comment inconsistency and add corresponding tests Mar 9, 2026
@YichiZhang0613
Copy link
Author

YichiZhang0613 commented Mar 9, 2026

@itsjunetime Hi, sorry for the interruption. Could you please review this PR when you have time? It's been open for two weeks and I'd appreciate any feedback. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant