Add workaround for tokio-rs/tokio#5502
This commit is contained in:
parent
7d973372cc
commit
f27e981259
3 changed files with 37 additions and 8 deletions
|
|
@ -20,6 +20,17 @@ pub trait AddGeneric<X: ToArtifact> {
|
|||
}
|
||||
|
||||
macro_rules! add_generic {
|
||||
// Workaround for https://github.com/tokio-rs/tokio/issues/5502
|
||||
() => (
|
||||
#[async_trait(?Send)]
|
||||
impl<SR, L, B, Rs, As> AddGeneric<()> for Setup<SR, L, B, Rs, As>
|
||||
{
|
||||
async fn add_generic(&self, (): ()) -> Result<(StoringLogger, (), bool), (StoringLogger, Box<dyn Error>)>
|
||||
{
|
||||
Ok((StoringLogger::default(), (), false))
|
||||
}
|
||||
}
|
||||
);
|
||||
( $($name:ident)* ) => (
|
||||
#[async_trait(?Send)]
|
||||
#[allow(non_snake_case)]
|
||||
|
|
@ -202,3 +213,19 @@ impl<SR: SymbolRunner, L, B> SymbolRunner for RegularSetupCore<SR, L, B> {
|
|||
result
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::super::setup::Setup;
|
||||
use super::AddGeneric;
|
||||
use crate::async_utils::run;
|
||||
use crate::DrySymbolRunner;
|
||||
|
||||
#[test]
|
||||
fn empty() {
|
||||
let setup: Setup<_, (), (), (), ()> = Setup::new(DrySymbolRunner);
|
||||
run(async {
|
||||
assert!(setup.add_generic(()).await.is_ok());
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod core;
|
||||
mod util;
|
||||
mod symbol_runner;
|
||||
mod util;
|
||||
pub use symbol_runner::{
|
||||
DelayingSymbolRunner, DrySymbolRunner, InitializingSymbolRunner, ReportingSymbolRunner,
|
||||
SymbolRunner,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,14 @@ struct SetupInner<CORE, Rs, As> {
|
|||
#[derive(Debug)]
|
||||
pub struct Setup<SR, L, B, Rs, As>(Rc<SetupInner<RegularSetupCore<SR, L, B>, Rs, As>>);
|
||||
|
||||
impl<SR, L, B, Rs, As> Setup<SR, L, B, Rs, As> {
|
||||
pub fn new(symbol_runner: SR) -> Self {
|
||||
Self(Rc::new(SetupInner {
|
||||
core: RegularSetupCore::new(symbol_runner),
|
||||
resources: RefCell::default(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
impl<L: 'static, B: 'static, SR: 'static, Rs: Hash + Eq + 'static, As: 'static>
|
||||
Setup<SR, L, B, Rs, As>
|
||||
{
|
||||
|
|
@ -111,13 +119,7 @@ impl<SR, LOG> SetupFacade<SR, LOG> {
|
|||
|
||||
impl<L, B, As, SR, LOG, Rs: Hash + Eq> SetupFacade<SR, LOG, L, B, Rs, As> {
|
||||
pub fn new_with(symbol_runner: SR, logger: LOG) -> Self {
|
||||
Self(
|
||||
logger,
|
||||
Setup(Rc::new(SetupInner {
|
||||
core: RegularSetupCore::new(symbol_runner),
|
||||
resources: RefCell::default(),
|
||||
})),
|
||||
)
|
||||
Self(logger, Setup::new(symbol_runner))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue