fix(defs): compile errors
This commit is contained in:
parent
d350462cf8
commit
ade818b043
@ -18,11 +18,15 @@ fn main() {
|
|||||||
// since it will be part of the scope.
|
// since it will be part of the scope.
|
||||||
scope.push("hello_there", "hello there");
|
scope.push("hello_there", "hello there");
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_module"))]
|
||||||
engine.register_static_module("general_kenobi", exported_module!(general_kenobi).into());
|
engine.register_static_module("general_kenobi", exported_module!(general_kenobi).into());
|
||||||
|
|
||||||
// Custom operators also show up in definitions.
|
// Custom operators also show up in definitions.
|
||||||
|
#[cfg(not(feature = "no_custom_syntax"))]
|
||||||
|
{
|
||||||
engine.register_custom_operator("minus", 100).unwrap();
|
engine.register_custom_operator("minus", 100).unwrap();
|
||||||
engine.register_fn("minus", |a: i64, b: i64| a - b);
|
engine.register_fn("minus", |a: i64, b: i64| a - b);
|
||||||
|
}
|
||||||
|
|
||||||
engine
|
engine
|
||||||
.eval_with_scope::<()>(
|
.eval_with_scope::<()>(
|
||||||
|
@ -169,13 +169,14 @@ impl<'e> Definitions<'e> {
|
|||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return name and definition pairs for each registered module.
|
/// Return module name and definition pairs for each registered module.
|
||||||
///
|
///
|
||||||
/// The definitions will always start with `module <module name>;`.
|
/// The definitions will always start with `module <module name>;`.
|
||||||
///
|
///
|
||||||
/// If the feature `no_module` is enabled, this will yield no elements.
|
/// If the feature `no_module` is enabled, this will yield no elements.
|
||||||
pub fn modules(&self) -> impl Iterator<Item = (String, String)> + '_ {
|
pub fn modules(&self) -> impl Iterator<Item = (String, String)> + '_ {
|
||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
|
let m = {
|
||||||
let mut m = self
|
let mut m = self
|
||||||
.engine
|
.engine
|
||||||
.global_sub_modules
|
.global_sub_modules
|
||||||
@ -188,10 +189,12 @@ impl<'e> Definitions<'e> {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
#[cfg(feature = "no_module")]
|
|
||||||
let mut m = Vec::new();
|
|
||||||
|
|
||||||
m.sort_by(|(name1, _), (name2, _)| name1.cmp(name2));
|
m.sort_by(|(name1, _), (name2, _)| name1.cmp(name2));
|
||||||
|
m
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "no_module")]
|
||||||
|
let m = Vec::new();
|
||||||
|
|
||||||
m.into_iter()
|
m.into_iter()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user