FIx no_std.

This commit is contained in:
Stephen Chung 2020-07-19 09:10:22 +08:00
parent 3ae7cf4018
commit 2f33edb762
3 changed files with 10 additions and 4 deletions

View File

@ -31,8 +31,8 @@ Opt-Out of Features
------------------ ------------------
Opt out of as many features as possible, if they are not needed, to reduce code size because, remember, by default Opt out of as many features as possible, if they are not needed, to reduce code size because, remember, by default
all code is compiled in as what a script requires cannot be predicted. If a language feature is not needed, all code is compiled into the final binary since what a script requires cannot be predicted.
omitting them via special features is a prudent strategy to optimize the build for size. If a language feature will never be needed, omitting it is a prudent strategy to optimize the build for size.
Omitting arrays ([`no_index`]) yields the most code-size savings, followed by floating-point support Omitting arrays ([`no_index`]) yields the most code-size savings, followed by floating-point support
([`no_float`]), checked arithmetic/script resource limits ([`unchecked`]) and finally object maps and custom types ([`no_object`]). ([`no_float`]), checked arithmetic/script resource limits ([`unchecked`]) and finally object maps and custom types ([`no_object`]).

View File

@ -7,3 +7,9 @@ The feature [`no_std`] automatically converts the scripting engine into a `no-st
Usually, a `no-std` build goes hand-in-hand with [minimal builds] because typical embedded Usually, a `no-std` build goes hand-in-hand with [minimal builds] because typical embedded
hardware (the primary target for `no-std`) has limited storage. hardware (the primary target for `no-std`) has limited storage.
Nightly Required
----------------
Currently, [`no_std`] requires the nightly compiler due to the crates that it uses.

View File

@ -25,7 +25,7 @@ use crate::stdlib::{
char, char,
collections::HashMap, collections::HashMap,
fmt, format, fmt, format,
hash::Hash, hash::{Hash, Hasher},
iter::empty, iter::empty,
mem, mem,
num::NonZeroUsize, num::NonZeroUsize,
@ -674,7 +674,7 @@ impl Default for Expr {
} }
impl Hash for Expr { impl Hash for Expr {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { fn hash<H: Hasher>(&self, state: &mut H) {
match self { match self {
Self::FloatConstant(x) => { Self::FloatConstant(x) => {
state.write(&x.0.to_le_bytes()); state.write(&x.0.to_le_bytes());