// Copyright 2025 Gabriel Bjørnager Jensen.

mod test;

use crate::Float;

use core::convert::Infallible;

/// Denotes a floating-point number that is at least as wide as [`f32`].
///
/// # Safety
///
/// Only primitive, floating-point types that fit the size requirement may implement this type.
pub trait FloatLeast32
where
	Self:
		crate::seal::FloatLeast32
		+ Float
		+ From<f32>
		+ From<u16>
		+ From<i16>
		+ TryFrom<f32, Error = Infallible>
		+ TryFrom<u16, Error = Infallible>
		+ TryFrom<i16, Error = Infallible>,
{}

macro_rules! impl_float_least32 {
	{ $($Ty:ty $(= $feature:literal)?),*$(,)? } => {$(
		$(#[cfg(feature = $feature)])?
		impl ::multitype::seal::FloatLeast32 for $Ty {}

		$(
			#[cfg(feature = $feature)]
			#[cfg_attr(feature = "unstable-docs", doc(cfg(feature = $feature)))]
		)?
		impl ::multitype::FloatLeast32 for $Ty {}
	)*};
}

impl_float_least32! {
	f32,
	f64,
	f128 = "f128",
}
