From 010a96dde36c67d333b1bcbbcd4087bc3fc4c171 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 22 Aug 2022 22:28:27 +0800 Subject: [PATCH] Fix feature builds. --- src/api/build_type.rs | 4 +++- src/api/deprecated.rs | 26 ++++++++++++++++++++------ src/api/register.rs | 4 +++- src/module/mod.rs | 4 +++- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/api/build_type.rs b/src/api/build_type.rs index d03c634c..20556eb7 100644 --- a/src/api/build_type.rs +++ b/src/api/build_type.rs @@ -1,12 +1,14 @@ //! Trait to build a custom type for use with [`Engine`]. #![allow(deprecated)] -use crate::func::register::Mut; use crate::{types::dynamic::Variant, Engine, Identifier, RegisterNativeFunction}; use std::marker::PhantomData; #[cfg(feature = "no_std")] use std::prelude::v1::*; +#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] +use crate::func::register::Mut; + /// Trait to build the API of a custom type for use with an [`Engine`] /// (i.e. register the type and its getters, setters, methods, etc.). /// diff --git a/src/api/deprecated.rs b/src/api/deprecated.rs index c12effbf..b1a06279 100644 --- a/src/api/deprecated.rs +++ b/src/api/deprecated.rs @@ -1,7 +1,6 @@ //! Module containing all deprecated API that will be removed in the next major version. -use crate::func::register::Mut; -use crate::func::{RegisterNativeFunction, SendSync}; +use crate::func::RegisterNativeFunction; use crate::types::dynamic::Variant; use crate::{ Dynamic, Engine, EvalAltResult, FnPtr, Identifier, ImmutableString, NativeCallContext, @@ -10,6 +9,9 @@ use crate::{ #[cfg(feature = "no_std")] use std::prelude::v1::*; +#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] +use crate::func::register::Mut; + #[cfg(not(feature = "no_std"))] #[cfg(not(target_family = "wasm"))] use std::path::PathBuf; @@ -165,7 +167,9 @@ impl Engine { pub fn register_get_result( &mut self, name: impl AsRef, - get_fn: impl RegisterNativeFunction<(Mut,), V, RhaiResultOf> + SendSync + 'static, + get_fn: impl RegisterNativeFunction<(Mut,), V, RhaiResultOf> + + crate::func::SendSync + + 'static, ) -> &mut Self { self.register_get(name, get_fn) } @@ -184,7 +188,9 @@ impl Engine { pub fn register_set_result( &mut self, name: impl AsRef, - set_fn: impl RegisterNativeFunction<(Mut, V), (), RhaiResultOf> + SendSync + 'static, + set_fn: impl RegisterNativeFunction<(Mut, V), (), RhaiResultOf> + + crate::func::SendSync + + 'static, ) -> &mut Self { self.register_set(name, set_fn) } @@ -215,7 +221,9 @@ impl Engine { S, >( &mut self, - get_fn: impl RegisterNativeFunction<(Mut, X), V, RhaiResultOf> + SendSync + 'static, + get_fn: impl RegisterNativeFunction<(Mut, X), V, RhaiResultOf> + + crate::func::SendSync + + 'static, ) -> &mut Self { self.register_indexer_get(get_fn) } @@ -244,7 +252,9 @@ impl Engine { S, >( &mut self, - set_fn: impl RegisterNativeFunction<(Mut, X, V), (), RhaiResultOf> + SendSync + 'static, + set_fn: impl RegisterNativeFunction<(Mut, X, V), (), RhaiResultOf> + + crate::func::SendSync + + 'static, ) -> &mut Self { self.register_indexer_set(set_fn) } @@ -424,6 +434,7 @@ impl<'a, T: Variant + Clone> crate::TypeBuilder<'a, T> { /// /// This method will be removed in the next major version. #[deprecated(since = "1.9.1", note = "use `with_get` instead")] + #[cfg(not(feature = "no_object"))] #[inline(always)] pub fn with_get_result( &mut self, @@ -445,6 +456,7 @@ impl<'a, T: Variant + Clone> crate::TypeBuilder<'a, T> { /// /// This method will be removed in the next major version. #[deprecated(since = "1.9.1", note = "use `with_set` instead")] + #[cfg(not(feature = "no_object"))] #[inline(always)] pub fn with_set_result( &mut self, @@ -468,6 +480,7 @@ impl<'a, T: Variant + Clone> crate::TypeBuilder<'a, T> { /// /// This method will be removed in the next major version. #[deprecated(since = "1.9.1", note = "use `with_indexer_get` instead")] + #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] #[inline(always)] pub fn with_indexer_get_result( &mut self, @@ -488,6 +501,7 @@ impl<'a, T: Variant + Clone> crate::TypeBuilder<'a, T> { /// /// This method will be removed in the next major version. #[deprecated(since = "1.9.1", note = "use `with_indexer_set` instead")] + #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] #[inline(always)] pub fn with_indexer_set_result( &mut self, diff --git a/src/api/register.rs b/src/api/register.rs index a2f9a56a..01b4f048 100644 --- a/src/api/register.rs +++ b/src/api/register.rs @@ -1,6 +1,5 @@ //! Module that defines the public function/module registration API of [`Engine`]. -use crate::func::register::Mut; use crate::func::{FnCallArgs, RegisterNativeFunction, SendSync}; use crate::types::dynamic::Variant; use crate::{ @@ -10,6 +9,9 @@ use std::any::{type_name, TypeId}; #[cfg(feature = "no_std")] use std::prelude::v1::*; +#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] +use crate::func::register::Mut; + impl Engine { /// Get the global namespace module (which is the fist module in `global_modules`). #[inline(always)] diff --git a/src/module/mod.rs b/src/module/mod.rs index b348058f..07d9c261 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1,7 +1,6 @@ //! Module defining external-loaded modules for Rhai. use crate::ast::FnAccess; -use crate::func::register::Mut; use crate::func::{ shared_take_or_clone, CallableFunction, FnCallArgs, IteratorFn, RegisterNativeFunction, SendSync, @@ -21,6 +20,9 @@ use std::{ ops::{Add, AddAssign}, }; +#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] +use crate::func::register::Mut; + /// A type representing the namespace of a function. #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "metadata", derive(serde::Serialize))]