Skip to content

Commit

Permalink
Merge pull request #869 from sdroege/futures-stable
Browse files Browse the repository at this point in the history
Generate pinned box futures and use the stabilized futures
  • Loading branch information
EPashkin committed Nov 11, 2019
2 parents 68eb6c5 + a14e610 commit 6c8c7c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/analysis/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ use std::{
collections::{HashMap, HashSet},
};

pub const CONSTRAINT_FUTURES: &str = "feature = \"futures\"";

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Visibility {
Public,
Expand Down Expand Up @@ -695,15 +693,13 @@ fn analyze_function(
if r#async && !commented {
if env.config.library_name != "Gio" {
imports.add("gio_sys");
imports.add_with_constraint("gio", version, Some(CONSTRAINT_FUTURES));
imports.add_with_constraint("gio", version, None);
}
imports.add("glib_sys");
imports.add("gobject_sys");
imports.add("std::ptr");
imports.add("std::boxed::Box as Box_");
if async_future.is_some() {
imports.add_with_constraint("futures::future", version, Some(CONSTRAINT_FUTURES));
}
imports.add("std::pin::Pin");

if let Some(ref trampoline) = trampoline {
for par in &trampoline.output_params {
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn generate(

writeln!(
w,
"{}{}#[cfg(any(feature = \"futures\", feature = \"dox\"))]",
"{}{}",
tabs(indent),
comment_prefix
)?;
Expand Down Expand Up @@ -168,7 +168,7 @@ pub fn declaration_futures(env: &Env, analysis: &analysis::functions::Info) -> S
let async_future = analysis.async_future.as_ref().unwrap();

let return_str = format!(
" -> Box_<dyn future::Future<Output = Result<{}, {}>> + std::marker::Unpin>",
" -> Pin<Box_<dyn std::future::Future<Output = Result<{}, {}>> + 'static>>",
async_future.success_parameters, async_future.error_parameters
);

Expand Down

0 comments on commit 6c8c7c4

Please sign in to comment.