floatd/
lib.rs

1//! Tiny crate that provides a "FloatD" trait, i.e. num_traits::Float + Debug + Display.
2//! This is likely to be subsumed into a successor crate once my project is more mature.
3//! For now, this is the most convenient place to keep the trait.
4//!
5//! According to the rust api guidelines chapter on [futureproofing](https://rust-lang.github.io/api-guidelines/future-proofing.html),
6//! specifying Display and Debug as trait bounds is bad practice.
7//!
8//! I think my downstream use case for this crate (guaranteeing a struct's underlying data can be formatted into an associated error type)
9//! falls under exception 1 listed in the guidelines. Your mileage may vary, though.
10
11// configure no_std if both std_math and std_errors features are inactive
12#![cfg_attr(not(feature = "std"), no_std)]
13
14use num_traits::Float;
15
16#[cfg(not(feature = "std"))]
17use core::fmt::Debug;
18#[cfg(not(feature = "std"))]
19use core::fmt::Display;
20
21#[cfg(feature = "std")]
22use std::fmt::Debug;
23#[cfg(feature = "std")]
24use std::fmt::Display;
25
26/// That's literally it, just Display + Debug + Float
27pub trait FloatD: Display + Debug + Float {}
28
29/// Empty impl
30impl<T: Display + Debug + Float> FloatD for T {}