cgmath/src/num.rs

74 lines
1.6 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.
2018-05-23 11:43:52 +00:00
use approx;
2014-05-26 17:10:04 +00:00
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-05-23 11:43:52 +00:00
pub trait BaseNum:
Copy
2018-01-03 02:01:02 +00:00
+ Clone
+ fmt::Debug
+ Num
+ NumCast
+ PartialOrd
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
2018-05-23 11:43:52 +00:00
+ RemAssign
{
2018-01-03 02:01:02 +00:00
}
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
2018-05-23 11:43:52 +00:00
pub trait BaseFloat:
BaseNum
+ Float
+ approx::AbsDiffEq<Epsilon = Self>
+ approx::RelativeEq<Epsilon = Self>
+ approx::UlpsEq<Epsilon = Self>
{
}
2014-05-26 17:10:04 +00:00
2018-01-03 02:01:02 +00:00
impl<T> BaseFloat for T
where
2018-05-23 11:43:52 +00:00
T: BaseNum
+ Float
+ approx::AbsDiffEq<Epsilon = Self>
+ approx::RelativeEq<Epsilon = Self>
+ approx::UlpsEq<Epsilon = Self>,
2018-01-03 02:01:02 +00:00
{
}