Skip to content

Commit

Permalink
simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Aug 20, 2024
1 parent 8bf662b commit bffe238
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
22 changes: 2 additions & 20 deletions crates/libs/bindgen/src/rust/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn type_is_exclusive(ty: &metadata::Type) -> bool {
}

fn is_default_async(interfaces: &[metadata::Interface]) -> Option<&metadata::Interface> {
let pos = interfaces.iter().position(|interface| {
interfaces.iter().find(|interface| {
if interface.kind == metadata::InterfaceKind::Default {
if let metadata::Type::TypeDef(def, _) = interface.ty {
if matches!(
Expand All @@ -272,23 +272,5 @@ fn is_default_async(interfaces: &[metadata::Interface]) -> Option<&metadata::Int
}
}
false
});

if let Some(pos) = pos {
if interfaces.len() == 1 {
return interfaces.get(0);
}

if interfaces.len() == 2 {
let info = if pos == 0 { 1 } else { 0 };

if let metadata::Type::TypeDef(def, _) = interfaces[info].ty {
if def.type_name() == metadata::TypeName::IAsyncInfo {
return interfaces.get(pos);
}
}
}
}

None
})
}
8 changes: 4 additions & 4 deletions crates/tests/futures/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn stream_async() -> Result<()> {
fn switch_context() -> Result<()> {
use futures::{executor::LocalPool, future, task::SpawnExt};
use std::future::IntoFuture;

let mut pool = LocalPool::new();
let (sender, receiver) = std::sync::mpsc::channel::<()>();

Expand All @@ -65,8 +65,8 @@ fn switch_context() -> Result<()> {
}
})
.unwrap();
let async_future = pool.run_until(select);

let async_future = pool.run_until(select);

pool.spawner()
.spawn(async move {
Expand All @@ -82,4 +82,4 @@ fn switch_context() -> Result<()> {
pool.run();

Ok(())
}
}

0 comments on commit bffe238

Please sign in to comment.