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
all code is compiled in as what a script requires cannot be predicted. If a language feature is not needed,
omitting them via special features is a prudent strategy to optimize the build for size.
all code is compiled into the final binary since what a script requires cannot be predicted.
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
([`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
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,
collections::HashMap,
fmt, format,
hash::Hash,
hash::{Hash, Hasher},
iter::empty,
mem,
num::NonZeroUsize,
@ -674,7 +674,7 @@ impl Default 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 {
Self::FloatConstant(x) => {
state.write(&x.0.to_le_bytes());