Skip to content

Commit

Permalink
Implement 'Object' for 'Arc<T: Object>' (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Nov 8, 2022
1 parent fef6366 commit 41ef953
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions minijinja/src/value/object.rs
Expand Up @@ -76,3 +76,21 @@ pub trait Object: fmt::Display + fmt::Debug + Any + Sync + Send {
))
}
}

impl<T: Object> Object for std::sync::Arc<T> {
fn get_attr(&self, name: &str) -> Option<Value> {
T::get_attr(self, name)
}

fn attributes(&self) -> Box<dyn Iterator<Item = &str> + '_> {
T::attributes(self)
}

fn call_method(&self, state: &State, name: &str, args: &[Value]) -> Result<Value, Error> {
T::call_method(self, state, name, args)
}

fn call(&self, state: &State, args: &[Value]) -> Result<Value, Error> {
T::call(self, state, args)
}
}

0 comments on commit 41ef953

Please sign in to comment.