refactor: 整理重构下载任务调度部分的代码,增强可读性和鲁棒性 (#531)
This commit is contained in:
@@ -18,12 +18,9 @@ pub trait NotifierAllExt {
|
||||
async fn notify_all(&self, client: &reqwest::Client, message: &str) -> Result<()>;
|
||||
}
|
||||
|
||||
impl NotifierAllExt for Option<Vec<Notifier>> {
|
||||
impl NotifierAllExt for Vec<Notifier> {
|
||||
async fn notify_all(&self, client: &reqwest::Client, message: &str) -> Result<()> {
|
||||
let Some(notifiers) = self else {
|
||||
return Ok(());
|
||||
};
|
||||
future::join_all(notifiers.iter().map(|notifier| notifier.notify(client, message))).await;
|
||||
future::join_all(self.iter().map(|notifier| notifier.notify(client, message))).await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user