Define 'apply_parameter' method on 'Project'

This commit is contained in:
KtorZ
2023-02-04 10:44:33 +01:00
parent 12f4768008
commit 592d3d7a1c
3 changed files with 42 additions and 8 deletions

View File

@@ -53,7 +53,10 @@ impl Blueprint<Schema> {
}
}
impl<T> Blueprint<T> {
impl<T> Blueprint<T>
where
T: Clone,
{
pub fn lookup(
&self,
title: Option<&String>,
@@ -83,10 +86,10 @@ impl<T> Blueprint<T> {
action: F,
) -> Result<A, E>
where
F: Fn(&Validator<T>) -> Result<A, E>,
F: Fn(Validator<T>) -> Result<A, E>,
{
match self.lookup(title, purpose) {
Some(LookupResult::One(validator)) => action(validator),
Some(LookupResult::One(validator)) => action(validator.to_owned()),
Some(LookupResult::Many) => Err(when_too_many(
self.validators
.iter()

View File

@@ -122,7 +122,12 @@ impl Validator<Schema> {
.unwrap(),
})
}
}
impl<T> Validator<T>
where
T: Clone,
{
pub fn apply(&mut self, arg: &Term<DeBruijn>) -> Result<(), Error> {
match self.parameters.split_first() {
None => Err(Error::NoParametersToApply),