Skip to content

Commit

Permalink
fix(lint): fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Sep 24, 2024
1 parent d5cf31a commit 7cf0c1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/aionbot-core/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::Result;
use state::TypeMap;

use crate::{entry::Entry, handler::Handler};
use crate::{entry::Entry, handler::Handler, types::SetupFn};

#[derive(Default)]
pub struct StateManager(pub(crate) TypeMap!(Send + Sync));
Expand All @@ -30,14 +30,14 @@ pub struct Builder<R: Runtime + Default> {
handler: Arc<Option<Handler>>,
runtime: R,
state: Arc<StateManager>,
setup: Option<Box<dyn FnOnce(&R) + Send + Sync>>,
setup: Option<SetupFn<R>>,
}

impl<R> Builder<R>
where
R: Runtime + Default + Send + 'static,
{
pub fn setup(&mut self, setup: Box<dyn FnOnce(&R) + Send + Sync>) {
pub fn setup(&mut self, setup: SetupFn<R>) {
self.setup = Some(setup);
}

Expand All @@ -52,7 +52,6 @@ where
}

pub async fn run(&mut self) -> Result<()> {
println!("Starting bot...");
self.runtime.prepare().await?;
if let Some(setup) = self.setup.take() {
self.runtime.setup(setup);
Expand Down Expand Up @@ -88,7 +87,7 @@ pub trait Runtime {
async move { Ok(()) }
}

fn setup(&mut self, setup: Box<dyn FnOnce(&Self) + Send + Sync>) {
fn setup(&mut self, setup: SetupFn<Self>) {
setup(self)
}

Expand Down
1 change: 1 addition & 0 deletions crates/aionbot-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ use crate::event::Event;

pub type HandlerCallback = BoxFuture<'static, Result<()>>;
pub type Callback = fn(Arc<Event>) -> HandlerCallback;
pub type SetupFn<R> = Box<dyn FnOnce(&R) + Send + Sync>;

0 comments on commit 7cf0c1e

Please sign in to comment.