#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Precision {
Single,
Double,
}
impl Precision {
pub const ACTIVE: Self = if cfg!(feature = "double-precision") {
Self::Double
} else {
Self::Single
};
pub const fn as_str(self) -> &'static str {
match self {
Self::Single => "single",
Self::Double => "double",
}
}
pub const fn is_double(self) -> bool {
matches!(self, Self::Double)
}
pub const fn pregenerated_bindings_file(self) -> &'static str {
match self {
Self::Single => "bindings_pregenerated.rs",
Self::Double => "bindings_double.rs",
}
}
pub const fn wasm_import_module(self) -> &'static str {
match self {
Self::Single => "box2d-sys-v2-single",
Self::Double => "box2d-sys-v2-double",
}
}
}
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct SinglePrecision;
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DoublePrecision;
#[cfg(not(feature = "double-precision"))]
pub type ActivePrecision = SinglePrecision;
#[cfg(feature = "double-precision")]
pub type ActivePrecision = DoublePrecision;
pub const ABI_PRECISION: Precision = Precision::ACTIVE;
pub const IS_DOUBLE_PRECISION: bool = ABI_PRECISION.is_double();