Skip to content

Add assertions#139

Open
YichiZhang0613 wants to merge 1 commit intoitsjunetime:mainfrom
YichiZhang0613:fix_inconsistency
Open

Add assertions#139
YichiZhang0613 wants to merge 1 commit intoitsjunetime:mainfrom
YichiZhang0613:fix_inconsistency

Conversation

@YichiZhang0613
Copy link

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
		}
	}

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