qubit_argument/argument/constraint/length_constraint.rs
1// =============================================================================
2// Copyright (c) 2025 - 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Relationships used by string and collection length constraints.
9
10/// A numeric relationship required of a measured string or collection length.
11///
12/// [`LengthMetric`](super::LengthMetric) identifies the measurement unit in a
13/// structured validation error.
14///
15/// ```compile_fail
16/// #![deny(unused_must_use)]
17/// use qubit_argument::LengthConstraint;
18///
19/// LengthConstraint::Exact(1);
20/// ```
21#[must_use]
22#[derive(Debug, Clone, PartialEq, Eq)]
23pub enum LengthConstraint {
24 /// Requires exactly the specified length.
25 Exact(usize),
26 /// Requires at least the specified length.
27 AtLeast(usize),
28 /// Requires at most the specified length.
29 AtMost(usize),
30 /// Requires a length between `min` and `max`, inclusive.
31 InRange {
32 /// The inclusive minimum length.
33 min: usize,
34 /// The inclusive maximum length.
35 max: usize,
36 },
37}