cgmath/src/num.rs

62 lines
1.4 KiB
Rust
Raw Normal View History

2014-05-26 17:10:04 +00:00
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
2015-03-14 02:49:46 +00:00
// refer to the Cargo.toml file at the top-level directory of this distribution.
2014-05-26 17:10:04 +00:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use approx::ApproxEq;
use std::fmt;
use std::ops::*;
2014-05-26 17:10:04 +00:00
use num_traits::{Float, Num, NumCast};
2015-04-05 01:19:11 +00:00
2014-05-26 17:10:04 +00:00
/// Base numeric types with partial ordering
2018-01-03 02:01:02 +00:00
pub trait BaseNum
: Copy
+ Clone
+ fmt::Debug
+ Num
+ NumCast
+ PartialOrd
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
+ RemAssign {
}
2014-05-26 17:10:04 +00:00
2018-01-03 02:01:02 +00:00
impl<T> BaseNum for T
where
T: Copy
+ Clone
+ fmt::Debug
+ Num
+ NumCast
+ PartialOrd
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
+ RemAssign,
{
}
2014-05-26 17:10:04 +00:00
/// Base floating point types
pub trait BaseFloat: BaseNum + Float + ApproxEq<Epsilon = Self> {}
2014-05-26 17:10:04 +00:00
2018-01-03 02:01:02 +00:00
impl<T> BaseFloat for T
where
T: BaseNum + Float + ApproxEq<Epsilon = Self>,
{
}