Refactor code base and split into more module files.
This commit is contained in:
35
src/module.rs
Normal file
35
src/module.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
//! Module defining external-loaded modules for Rhai.
|
||||
|
||||
use crate::any::Dynamic;
|
||||
|
||||
use crate::stdlib::{
|
||||
collections::HashMap,
|
||||
ops::{Deref, DerefMut},
|
||||
string::String,
|
||||
};
|
||||
|
||||
/// An imported module.
|
||||
///
|
||||
/// Not available under the `no_module` feature.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Module(HashMap<String, Dynamic>);
|
||||
|
||||
impl Module {
|
||||
/// Create a new module.
|
||||
pub fn new() -> Self {
|
||||
Self(HashMap::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Module {
|
||||
type Target = HashMap<String, Dynamic>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Module {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user