Use no-std-compat to build no-std.

This commit is contained in:
Stephen Chung
2021-04-17 15:15:54 +08:00
parent 2f2b7403cb
commit 01f0cc028b
48 changed files with 293 additions and 293 deletions

View File

@@ -2,10 +2,12 @@
use super::str::StringSliceDeserializer;
use crate::dynamic::Union;
use crate::stdlib::{any::type_name, boxed::Box, fmt, string::ToString};
use crate::{Dynamic, EvalAltResult, ImmutableString, LexError, Position};
use serde::de::{DeserializeSeed, Error, IntoDeserializer, MapAccess, SeqAccess, Visitor};
use serde::{Deserialize, Deserializer};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{any::type_name, fmt};
#[cfg(not(feature = "no_index"))]
use crate::Array;

View File

@@ -1,8 +1,10 @@
//! Implementations of [`serde::Deserialize`].
use crate::stdlib::{fmt, string::ToString};
use crate::{Dynamic, ImmutableString, INT};
use serde::de::{Deserialize, Deserializer, Error, Visitor};
use std::fmt;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
#[cfg(not(feature = "no_index"))]
use crate::Array;
@@ -95,8 +97,8 @@ impl<'d> Visitor<'d> for DynamicVisitor {
#[cfg(feature = "no_float")]
#[cfg(feature = "decimal")]
fn visit_f32<E: Error>(self, v: f32) -> Result<Self::Value, E> {
use crate::stdlib::convert::TryFrom;
use rust_decimal::Decimal;
use std::convert::TryFrom;
Decimal::try_from(v)
.map(|v| v.into())
@@ -105,8 +107,8 @@ impl<'d> Visitor<'d> for DynamicVisitor {
#[cfg(feature = "no_float")]
#[cfg(feature = "decimal")]
fn visit_f64<E: Error>(self, v: f64) -> Result<Self::Value, E> {
use crate::stdlib::convert::TryFrom;
use rust_decimal::Decimal;
use std::convert::TryFrom;
Decimal::try_from(v)
.map(|v| v.into())

View File

@@ -1,11 +1,8 @@
use crate::stdlib::{
cmp::Ordering,
collections::BTreeMap,
string::{String, ToString},
vec::Vec,
};
use crate::{Engine, AST};
use serde::{Deserialize, Serialize};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{cmp::Ordering, collections::BTreeMap};
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]

View File

@@ -1,11 +1,13 @@
//! Implement serialization support of [`Dynamic`][crate::Dynamic] for [`serde`].
use crate::stdlib::{boxed::Box, fmt, string::ToString};
use crate::{Dynamic, EvalAltResult, Position, RhaiResult};
use serde::ser::{
Error, SerializeMap, SerializeSeq, SerializeStruct, SerializeTuple, SerializeTupleStruct,
};
use serde::{Serialize, Serializer};
use std::fmt;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
#[cfg(not(feature = "no_index"))]
use crate::Array;
@@ -220,8 +222,8 @@ impl Serializer for &mut DynamicSerializer {
#[cfg(feature = "no_float")]
#[cfg(feature = "decimal")]
{
use crate::stdlib::convert::TryFrom;
use rust_decimal::Decimal;
use std::convert::TryFrom;
Decimal::try_from(v)
.map(|v| v.into())
@@ -236,8 +238,8 @@ impl Serializer for &mut DynamicSerializer {
#[cfg(feature = "no_float")]
#[cfg(feature = "decimal")]
{
use crate::stdlib::convert::TryFrom;
use rust_decimal::Decimal;
use std::convert::TryFrom;
Decimal::try_from(v)
.map(|v| v.into())
@@ -539,7 +541,7 @@ impl SerializeMap for DynamicSerializer {
) -> Result<(), Box<EvalAltResult>> {
#[cfg(not(feature = "no_object"))]
{
let key = crate::stdlib::mem::take(&mut self._key)
let key = std::mem::take(&mut self._key)
.take_immutable_string()
.map_err(|typ| {
EvalAltResult::ErrorMismatchDataType(

View File

@@ -1,9 +1,10 @@
//! Implementations of [`serde::Serialize`].
use crate::dynamic::{Union, Variant};
use crate::stdlib::string::ToString;
use crate::{Dynamic, ImmutableString};
use serde::ser::{Serialize, Serializer};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
#[cfg(not(feature = "no_object"))]
use serde::ser::SerializeMap;

View File

@@ -1,8 +1,10 @@
//! Implement deserialization support of [`ImmutableString`][crate::ImmutableString] for [`serde`].
use crate::stdlib::{any::type_name, boxed::Box};
use crate::{EvalAltResult, Position};
use serde::de::{Deserializer, Visitor};
use std::any::type_name;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
/// Deserializer for `ImmutableString`.
pub struct StringSliceDeserializer<'a> {