devela/num/dom/real/float/wrapper/
definition.rs1#[doc = crate::_tags!(num namespace optional_std)]
8#[doc = crate::_doc_meta!{location("num/dom/real")}]
10#[doc = crate::doclink!(custom devela "[`FloatExt`]" "num/trait.FloatExt.html")]
13#[must_use]
21#[repr(transparent)]
22pub struct Float<T>(pub T);
23
24crate::_num_dom_impl_arith![Float: f32, f64];
25#[cfg(nightly_float)]
26crate::_num_dom_impl_arith![Float: f16, f128];
27
28#[rustfmt::skip]
29mod core_impls {
30 use super::Float;
31 use crate::{ConstInit, Debug, Display, FmtResult, Formatter, Ordering};
32
33 impl<T: ConstInit> ConstInit for Float<T> {
34 const INIT: Self = Float(T::INIT);
35 }
36
37 impl<T: Clone> Clone for Float<T> {
38 fn clone(&self) -> Self { Self(self.0.clone()) }
39 }
40 impl<T: Copy> Copy for Float<T> {}
41 impl<T: Debug> Debug for Float<T> {
42 fn fmt(&self, f: &mut Formatter) -> FmtResult<()> {
43 f.debug_tuple("Float").field(&self.0).finish()
44 }
45 }
46 impl<T: Display> Display for Float<T> {
47 fn fmt(&self, f: &mut Formatter) -> FmtResult<()> { Display::fmt(&self.0, f) }
48 }
49
50 impl<T: PartialEq> PartialEq for Float<T> {
51 fn eq(&self, other: &Self) -> bool { self.0.eq(&other.0) }
52 }
53 impl<T: PartialEq> PartialEq<T> for Float<T> {
54 fn eq(&self, other: &T) -> bool { self.0.eq(other) }
55 }
56
57 impl<T: PartialOrd> PartialOrd for Float<T> {
58 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
59 self.0.partial_cmp(&other.0)
60 }
61 }
62 impl<T: PartialOrd> PartialOrd<T> for Float<T> {
63 fn partial_cmp(&self, other: &T) -> Option<Ordering> {
64 self.0.partial_cmp(other)
65 }
66 }
67 }