qubit_metadata/number_comparison_policy.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9//! [`NumberComparisonPolicy`] — mixed integer/float handling for range predicates.
10
11use serde::{Deserialize, Serialize};
12
13/// Policy that controls mixed integer/float number comparisons.
14///
15/// This policy only applies to range predicates (`greater`, `greater_equal`,
16/// `less`, `less_equal`) when operands are numeric.
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
18pub enum NumberComparisonPolicy {
19 /// Preserve precision and return "incomparable" for risky mixed comparisons.
20 ///
21 /// This is the historical behavior and therefore the default.
22 #[default]
23 Conservative,
24 /// Allow lossy `f64` fallback for mixed comparisons that are otherwise
25 /// incomparable under [`NumberComparisonPolicy::Conservative`].
26 Approximate,
27}