1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2014 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! A one-dimensional length, tagged with its units.
use num_traits;
// Euclid has its own Zero and One traits instead of of using the num_traits equivalents.
// Unfortunately, num_traits::Zero requires Add, which opens a bag of sad things:
// - Most importantly, for Point2D to implement Zero it would need to implement Add<Self> which we
// don't want (we allow "Point + Vector" and "Vector + Vector" semantics and purposefully disallow
// "Point + Point".
// - Some operations that require, say, One and Div (for example Scale::inv) currently return a
// type parameterized over T::Output which is ambiguous with num_traits::One because it inherits
// Mul which also has an Output associated type. To fix it need to complicate type signatures
// by using <T as Trait>::Output which makes the code and documentation harder to read.
//
// On the other hand, euclid::num::Zero/One are automatically implemented for all types that
// implement their num_traits counterpart. Euclid users never need to explicitly use
// euclid::num::Zero/One and can/should only manipulate the num_traits equivalents without risk
// of compatibility issues with euclid.
/// Defines the nearest integer value to the original value.
/// Defines the biggest integer equal or lower than the original value.
/// Defines the smallest integer equal or greater than the original value.
num_int!;
num_int!;
num_int!;
num_int!;
num_int!;
num_int!;
num_int!;
num_int!;
num_float!;
num_float!;