From 93d67be73d5341d2edcf6fee09ed08675095f019 Mon Sep 17 00:00:00 2001 From: indirection42 Date: Fri, 5 Jul 2024 09:58:39 +0800 Subject: [PATCH] fix no_std --- xcq-types/src/impls.rs | 2 +- xcq-types/src/lib.rs | 4 ++++ xcq-types/src/prelude.rs | 2 -- xcq-types/src/ty/enum.rs | 2 +- xcq-types/src/ty/field.rs | 1 + xcq-types/src/ty/mod.rs | 1 + xcq-types/src/ty/struct.rs | 3 +-- 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xcq-types/src/impls.rs b/xcq-types/src/impls.rs index d32a0dc..e04cbf8 100644 --- a/xcq-types/src/impls.rs +++ b/xcq-types/src/impls.rs @@ -1,4 +1,4 @@ -use crate::{boxed::Box, rc::Rc, sync::Arc}; +use crate::{boxed::Box, rc::Rc, string::String, sync::Arc, vec::Vec}; use crate::{EnumType, Field, PrimitiveType, StructType, Variant}; use crate::{XcqType, XcqTypeInfo}; use fortuples::fortuples; diff --git a/xcq-types/src/lib.rs b/xcq-types/src/lib.rs index efd49ee..c79d395 100644 --- a/xcq-types/src/lib.rs +++ b/xcq-types/src/lib.rs @@ -1,5 +1,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +#[cfg(not(feature = "std"))] +#[macro_use] +extern crate alloc; + mod ty; pub use ty::*; mod impls; diff --git a/xcq-types/src/prelude.rs b/xcq-types/src/prelude.rs index 71fbd7f..d7702f1 100644 --- a/xcq-types/src/prelude.rs +++ b/xcq-types/src/prelude.rs @@ -1,5 +1,3 @@ -#[cfg(not(feature = "std"))] -extern crate alloc; use cfg_if::cfg_if; diff --git a/xcq-types/src/ty/enum.rs b/xcq-types/src/ty/enum.rs index ea32aa0..7c51a0b 100644 --- a/xcq-types/src/ty/enum.rs +++ b/xcq-types/src/ty/enum.rs @@ -1,4 +1,4 @@ -use crate::Field; +use crate::{vec::Vec, Field}; #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)] pub struct Variant { diff --git a/xcq-types/src/ty/field.rs b/xcq-types/src/ty/field.rs index e2a8158..a280122 100644 --- a/xcq-types/src/ty/field.rs +++ b/xcq-types/src/ty/field.rs @@ -1,3 +1,4 @@ +use crate::vec::Vec; use crate::XcqType; // A Named or Unnamed field in a composite type #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)] diff --git a/xcq-types/src/ty/mod.rs b/xcq-types/src/ty/mod.rs index d4aed9d..ad7aaf9 100644 --- a/xcq-types/src/ty/mod.rs +++ b/xcq-types/src/ty/mod.rs @@ -2,6 +2,7 @@ mod r#enum; mod field; mod primitive; mod r#struct; +use crate::{boxed::Box, vec::Vec}; pub use self::{field::*, primitive::*, r#enum::*, r#struct::*}; diff --git a/xcq-types/src/ty/struct.rs b/xcq-types/src/ty/struct.rs index e21886b..3fb5ead 100644 --- a/xcq-types/src/ty/struct.rs +++ b/xcq-types/src/ty/struct.rs @@ -1,5 +1,4 @@ -use crate::prelude::vec::Vec; -use crate::Field; +use crate::{vec::Vec, Field}; /// A struct type, consisting of a named (struct) or unnamed (tuple struct) fields or unit struct. /// Note: in fact, it can represent a