argmin/core/float.rs
1// Copyright 2018-2024 argmin developers
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8use crate::core::{kv::KvValue, SendAlias};
9use num_traits::{Float, FloatConst, FromPrimitive, ToPrimitive};
10use std::fmt::{Debug, Display};
11
12/// An alias for float types (`f32`, `f64`) which combines multiple commonly needed traits from
13/// `num_traits`, `std::fmt` and for serialization/deserialization (the latter only if the `serde1`
14/// feature is enabled). It is automatically implemented for all types which fulfill the trait
15/// bounds.
16pub trait ArgminFloat:
17 'static
18 + Float
19 + FloatConst
20 + FromPrimitive
21 + ToPrimitive
22 + Debug
23 + Display
24 + SendAlias
25 + Into<KvValue>
26{
27}
28
29/// `ArgminFloat` is automatically implemented for all types which fulfill the trait bounds.
30impl<I> ArgminFloat for I where
31 I: 'static
32 + Float
33 + FloatConst
34 + FromPrimitive
35 + ToPrimitive
36 + Debug
37 + Display
38 + SendAlias
39 + Into<KvValue>
40{
41}