aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/macro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r--src/makefile/macro.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs
index b135f42..4a82fe9 100644
--- a/src/makefile/macro.rs
+++ b/src/makefile/macro.rs
@@ -11,6 +11,7 @@ use std::rc::Rc;
use super::functions;
use super::token::{Token, TokenString};
use super::ItemSource;
+use super::LookupInternal;
#[cfg(feature = "full")]
use crate::makefile::eval_context::DeferredEvalContext;
use eyre::{bail, Result, WrapErr};
@@ -25,10 +26,6 @@ pub struct Macro {
pub eagerly_expanded: bool,
}
-pub trait LookupInternal: for<'a> Fn(&'a str) -> Result<String> {}
-
-impl<F: for<'a> Fn(&'a str) -> Result<String>> LookupInternal for F {}
-
#[cfg(feature = "full")]
#[derive(Clone, Debug)]
pub enum ExportConfig {
@@ -91,7 +88,7 @@ impl ExportConfig {
pub struct Set<'parent, 'lookup> {
parent: Option<&'parent Set<'parent, 'lookup>>,
pub data: HashMap<String, Macro>,
- lookup_internal: Option<&'lookup dyn LookupInternal>,
+ lookup_internal: Option<LookupInternal<'lookup>>,
#[cfg(feature = "full")]
pub exported: ExportConfig,
warnings: Rc<RefCell<HashSet<String>>>,
@@ -140,8 +137,8 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> {
}
fn lookup_internal(&self, name: &str) -> Result<String> {
- if let Some(lookup) = self.lookup_internal {
- lookup(name)
+ if let Some(lookup) = self.lookup_internal.as_ref() {
+ lookup.lookup(name)
} else if let Some(parent) = self.parent {
parent.lookup_internal(name)
} else {
@@ -341,7 +338,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> {
}
}
- pub fn with_lookup<'l, 's: 'l>(&'s self, lookup: &'l dyn LookupInternal) -> Set<'s, 'l> {
+ pub fn with_lookup<'l, 's: 'l>(&'s self, lookup: LookupInternal<'l>) -> Set<'s, 'l> {
Set {
parent: Some(self),
data: HashMap::new(),
@@ -392,7 +389,10 @@ impl fmt::Debug for Set<'_, '_> {
let mut r#struct = f.debug_struct("Set");
r#struct.field("parent", &self.parent);
r#struct.field("data", &self.data);
- r#struct.field("lookup_internal", &self.lookup_internal.map(|_| ()));
+ r#struct.field(
+ "lookup_internal",
+ &self.lookup_internal.as_ref().map(|_| ()),
+ );
#[cfg(feature = "full")]
r#struct.field("exported", &self.exported);
r#struct.field("warnings", &self.warnings);