Build Module type plus engine hooks.

This commit is contained in:
Stephen Chung
2020-05-05 15:00:10 +08:00
parent c03b162b7e
commit 38e717a838
14 changed files with 249 additions and 134 deletions

View File

@@ -60,7 +60,7 @@ pub struct Entry<'a> {
/// allowing for automatic _shadowing_.
///
/// Currently, `Scope` is neither `Send` nor `Sync`. Turn on the `sync` feature to make it `Send + Sync`.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Scope<'a>(Vec<Entry<'a>>);
impl<'a> Scope<'a> {
@@ -77,7 +77,7 @@ impl<'a> Scope<'a> {
/// assert_eq!(my_scope.get_value::<i64>("x").unwrap(), 42);
/// ```
pub fn new() -> Self {
Self(Vec::new())
Default::default()
}
/// Empty the Scope.
@@ -177,7 +177,7 @@ impl<'a> Scope<'a> {
name,
EntryType::Module,
Dynamic(Union::Module(Box::new(value))),
true,
false,
);
}
@@ -422,12 +422,6 @@ impl<'a> Scope<'a> {
}
}
impl Default for Scope<'_> {
fn default() -> Self {
Scope::new()
}
}
impl<'a, K: Into<Cow<'a, str>>> iter::Extend<(K, EntryType, Dynamic)> for Scope<'a> {
fn extend<T: IntoIterator<Item = (K, EntryType, Dynamic)>>(&mut self, iter: T) {
self.0