aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/asset/dispatcher.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/asset/dispatcher.rs')
-rw-r--r--mingling_core/src/asset/dispatcher.rs40
1 files changed, 33 insertions, 7 deletions
diff --git a/mingling_core/src/asset/dispatcher.rs b/mingling_core/src/asset/dispatcher.rs
index 8f04955..cb0987d 100644
--- a/mingling_core/src/asset/dispatcher.rs
+++ b/mingling_core/src/asset/dispatcher.rs
@@ -32,22 +32,48 @@ where
C: ProgramCollect<Enum = C>,
{
/// Adds a dispatcher to the program.
- #[cfg(not(feature = "dispatch_tree"))]
- pub fn with_dispatcher<Disp>(&mut self, dispatcher: Disp)
+ #[cfg_attr(
+ feature = "dispatch_tree",
+ deprecated(
+ note = "When the `dispatch_tree` feature is enabled, the `dispatcher` field no longer exists inside Program. All types are collected at compile time by the `gen_program!()` macro, so the `with_dispatcher` function is no longer needed"
+ )
+ )]
+ pub fn with_dispatcher<Disp>(&mut self, dispatcher: Disp) -> &mut Self
where
Disp: Dispatcher<C> + Send + Sync + 'static,
{
- self.dispatcher.push(Box::new(dispatcher));
+ #[cfg(not(feature = "dispatch_tree"))]
+ {
+ self.dispatcher.push(Box::new(dispatcher));
+ }
+ #[cfg(feature = "dispatch_tree")]
+ {
+ let _ = dispatcher;
+ }
+ self
}
/// Add some dispatchers to the program.
- #[cfg(not(feature = "dispatch_tree"))]
- pub fn with_dispatchers<D>(&mut self, dispatchers: D)
+ #[cfg_attr(
+ feature = "dispatch_tree",
+ deprecated(
+ note = "When the `dispatch_tree` feature is enabled, the `dispatcher` field no longer exists inside Program. All types are collected at compile time by the `gen_program!()` macro, so the `with_dispatcher` function is no longer needed"
+ )
+ )]
+ pub fn with_dispatchers<D>(&mut self, dispatchers: D) -> &mut Self
where
D: Into<Dispatchers<C>>,
{
- let dispatchers = dispatchers.into();
- self.dispatcher.extend(dispatchers.dispatcher);
+ #[cfg(not(feature = "dispatch_tree"))]
+ {
+ let dispatchers = dispatchers.into();
+ self.dispatcher.extend(dispatchers.dispatcher);
+ }
+ #[cfg(feature = "dispatch_tree")]
+ {
+ let _ = dispatchers;
+ }
+ self
}
}