Fixing unused lifetimes

This commit is contained in:
wrk 2023-05-30 21:52:54 +02:00
parent bb0c672f8f
commit 1a51ebcd44
2 changed files with 15 additions and 15 deletions

View File

@ -266,20 +266,20 @@ impl Context {
} }
} }
pub fn add_system<I, S: for<'a> System<'a> + Send + Sync + 'static>( pub fn add_system<I, S: for<'a> System + Send + Sync + 'static>(
&mut self, &mut self,
name: &str, name: &str,
system: impl for<'a> IntoSystem<'a, I, System = S>, system: impl for<'a> IntoSystem<I, System = S>,
) -> &mut Self { ) -> &mut Self {
self.systems self.systems
.insert(name.to_owned(), Box::new(system.into_system())); .insert(name.to_owned(), Box::new(system.into_system()));
self self
} }
pub fn add_interval_task<I, S: for<'a> System<'a> + Send + Sync + 'static>( pub fn add_interval_task<I, S: for<'a> System + Send + Sync + 'static>(
&mut self, &mut self,
duration: Duration, duration: Duration,
system_task: impl for<'a> IntoSystem<'a, I, System = S>, system_task: impl for<'a> IntoSystem<I, System = S>,
) -> &mut Self { ) -> &mut Self {
self.interval_tasks self.interval_tasks
.push((duration, Box::new(system_task.into_system()))); .push((duration, Box::new(system_task.into_system())));
@ -361,10 +361,10 @@ impl Irc {
}) })
} }
pub async fn add_system<I, S: for<'a> System<'a> + Send + Sync + 'static>( pub async fn add_system<I, S: for<'a> System + Send + Sync + 'static>(
&mut self, &mut self,
name: &str, name: &str,
system: impl for<'a> IntoSystem<'a, I, System = S>, system: impl for<'a> IntoSystem<I, System = S>,
) -> &mut Self { ) -> &mut Self {
{ {
let mut context = self.context.write().await; let mut context = self.context.write().await;
@ -373,10 +373,10 @@ impl Irc {
self self
} }
pub async fn add_interval_task<I, S: for<'a> System<'a> + Send + Sync + 'static>( pub async fn add_interval_task<I, S: for<'a> System + Send + Sync + 'static>(
&mut self, &mut self,
duration: Duration, duration: Duration,
system: impl for<'a> IntoSystem<'a, I, System = S>, system: impl for<'a> IntoSystem<I, System = S>,
) -> &mut Self { ) -> &mut Self {
{ {
let mut context = self.context.write().await; let mut context = self.context.write().await;

View File

@ -7,12 +7,12 @@ pub struct FunctionSystem<Input, F> {
marker: PhantomData<fn() -> Input>, marker: PhantomData<fn() -> Input>,
} }
pub trait System<'a> { pub trait System {
fn run(&mut self, prefix: &'a IrcPrefix, factory: &'a mut Factory) -> Response; fn run(&mut self, prefix: &IrcPrefix, factory: &mut Factory) -> Response;
} }
pub trait IntoSystem<'a, Input> { pub trait IntoSystem<Input> {
type System: System<'a>; type System: System;
fn into_system(self) -> Self::System; fn into_system(self) -> Self::System;
} }
@ -23,7 +23,7 @@ macro_rules! impl_system {
) => { ) => {
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[allow(unused)] #[allow(unused)]
impl<F, R: IntoResponse, $($params: SystemParam),*> System<'_> for FunctionSystem<($($params,)*), F> impl<F, R: IntoResponse, $($params: SystemParam),*> System for FunctionSystem<($($params,)*), F>
where where
for<'a, 'b> &'a mut F: for<'a, 'b> &'a mut F:
FnMut( $($params),* ) -> R + FnMut( $($params),* ) -> R +
@ -51,7 +51,7 @@ macro_rules! impl_into_system {
( (
$($params:ident),* $($params:ident),*
) => { ) => {
impl<F, R: IntoResponse, $($params: SystemParam),*> IntoSystem<'_, ($($params,)*)> for F impl<F, R: IntoResponse, $($params: SystemParam),*> IntoSystem<($($params,)*)> for F
where where
for<'a, 'b> &'a mut F: for<'a, 'b> &'a mut F:
FnMut( $($params),* ) -> R + FnMut( $($params),* ) -> R +
@ -81,7 +81,7 @@ impl_into_system!(T1, T2);
impl_into_system!(T1, T2, T3); impl_into_system!(T1, T2, T3);
impl_into_system!(T1, T2, T3, T4); impl_into_system!(T1, T2, T3, T4);
pub(crate) type StoredSystem = Box<dyn for<'a> System<'a> + Send + Sync>; pub(crate) type StoredSystem = Box<dyn for<'a> System + Send + Sync>;
pub(crate) trait SystemParam { pub(crate) trait SystemParam {
type Item<'new>; type Item<'new>;