Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Arnab Animesh Das
rusttype
Commits
a73a9bf0
Verified
Commit
a73a9bf0
authored
Apr 10, 2020
by
Alex Butler
Browse files
Fix no_std build
parent
a562189b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Cargo.toml
View file @
a73a9bf0
...
...
@@ -48,7 +48,7 @@ default = ["std"]
# Activates usage of std.
std
=
[
"has-atomics"
,
"ttf-parser/default"
,
"ab_glyph_rasterizer/default"
]
# Uses libm when not using std. This needs to be active in that case.
libm-math
=
["libm"]
libm-math
=
[
"libm"
,
"ab_glyph_rasterizer/libm"
]
# Some targets don't have atomics, this activates usage of Arc<T> instead of Rc<T>.
has-atomics
=
[]
# Adds `gpu_cache` module
...
...
src/geometry.rs
View file @
a73a9bf0
use
core
::
ops
;
#[cfg(all(feature
=
"libm-math"
,
not(feature
=
"std"
)))]
use
crate
::
nostd_float
::
FloatExt
;
/// A point in 2-dimensional space, with each dimension of type `N`.
///
/// Legal operations on points are addition and subtraction by vectors, and
...
...
src/lib.rs
View file @
a73a9bf0
...
...
@@ -114,8 +114,6 @@ use core::fmt;
#[cfg(all(feature
=
"libm-math"
,
not(feature
=
"std"
)))]
use
crate
::
nostd_float
::
FloatExt
;
#[cfg(not(feature
=
"std"
))]
use
alloc
::
vec
::
Vec
;
/// Good enough relatively equal test for floats.
macro_rules!
relative_eq
{
...
...
src/nostd_float.rs
View file @
a73a9bf0
pub
(
crate
)
trait
FloatExt
{
fn
floor
(
self
)
->
Self
;
fn
ceil
(
self
)
->
Self
;
fn
sqrt
(
self
)
->
Self
;
fn
fract
(
self
)
->
Self
;
fn
trunc
(
self
)
->
Self
;
fn
round
(
self
)
->
Self
;
...
...
@@ -18,10 +17,6 @@ impl FloatExt for f32 {
libm
::
ceilf
(
self
)
}
#[inline]
fn
sqrt
(
self
)
->
Self
{
libm
::
sqrtf
(
self
)
}
#[inline]
fn
fract
(
self
)
->
Self
{
self
-
self
.trunc
()
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment