Skip to content

Commit

Permalink
Use futures-core and futures-tasks via futures-util.
Browse files Browse the repository at this point in the history
Just to reduce number of dependencies.
  • Loading branch information
khvzak committed May 28, 2023
1 parent 6dee339 commit e0224ab
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 18 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ luau = ["ffi/luau"]
luau-jit = ["luau", "ffi/luau-codegen"]
vendored = ["ffi/vendored"]
module = ["mlua_derive", "ffi/module"]
async = ["futures-core", "futures-task", "futures-util"]
async = ["futures-util"]
send = []
serialize = ["serde", "erased-serde", "serde-value"]
macros = ["mlua_derive/macros"]
Expand All @@ -47,9 +47,7 @@ bstr = { version = "1.0", features = ["std"], default_features = false }
once_cell = { version = "1.0" }
num-traits = { version = "0.2.14" }
rustc-hash = "1.0"
futures-core = { version = "0.3.5", optional = true }
futures-task = { version = "0.3.5", optional = true }
futures-util = { version = "0.3.5", optional = true }
futures-util = { version = "0.3", optional = true, default-features = false, features = ["std"] }
serde = { version = "1.0", optional = true }
erased-serde = { version = "0.3", optional = true }
serde-value = { version = "0.7", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::lua::Lua;
use crate::value::{FromLuaMulti, IntoLua, IntoLuaMulti, Value};

#[cfg(feature = "async")]
use {futures_core::future::LocalBoxFuture, futures_util::future};
use futures_util::future::{self, LocalBoxFuture};

/// Trait for types [loadable by Lua] and convertible to a [`Chunk`]
///
Expand Down
3 changes: 1 addition & 2 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use crate::value::{FromLuaMulti, IntoLua, IntoLuaMulti};
#[cfg(feature = "async")]
use {
crate::types::AsyncCallback,
futures_core::future::{Future, LocalBoxFuture},
futures_util::{future, TryFutureExt},
futures_util::future::{self, Future, LocalBoxFuture, TryFutureExt},
};

/// Handle to an internal Lua function.
Expand Down
8 changes: 2 additions & 6 deletions src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ use crate::{chunk::Compiler, types::VmState};
#[cfg(feature = "async")]
use {
crate::types::{AsyncCallback, AsyncCallbackUpvalue, AsyncPollUpvalue},
futures_task::noop_waker_ref,
futures_util::future::{self, TryFutureExt},
std::{
future::Future,
task::{Context, Poll, Waker},
},
futures_util::future::{self, Future, TryFutureExt},
futures_util::task::{noop_waker_ref, Context, Poll, Waker},
};

#[cfg(feature = "serialize")]
Expand Down
2 changes: 1 addition & 1 deletion src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::value::{FromLua, FromLuaMulti, IntoLua, IntoLuaMulti, MultiValue, Val
use crate::userdata::USER_VALUE_MAXSLOT;

#[cfg(feature = "async")]
use futures_core::future::Future;
use std::future::Future;

/// Constructed by the [`Lua::scope`] method, allows temporarily creating Lua userdata and
/// callbacks that are not required to be Send or 'static.
Expand Down
2 changes: 1 addition & 1 deletion src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::util::{assert_stack, check_stack, StackGuard};
use crate::value::{FromLua, FromLuaMulti, IntoLua, IntoLuaMulti, Nil, Value};

#[cfg(feature = "async")]
use {futures_core::future::LocalBoxFuture, futures_util::future};
use futures_util::future::{self, LocalBoxFuture};

/// Handle to an internal Lua table.
#[derive(Clone)]
Expand Down
3 changes: 2 additions & 1 deletion src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use {
lua::ASYNC_POLL_PENDING,
value::{MultiValue, Value},
},
futures_core::{future::Future, stream::Stream},
futures_util::stream::Stream,
std::{
future::Future,
marker::PhantomData,
pin::Pin,
ptr::NonNull,
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{fmt, mem, ptr};
use std::ffi::CStr;

#[cfg(feature = "async")]
use futures_core::future::LocalBoxFuture;
use futures_util::future::LocalBoxFuture;

use crate::error::Result;
#[cfg(not(feature = "luau"))]
Expand Down
2 changes: 1 addition & 1 deletion src/userdata_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::userdata::{AnyUserData, MetaMethod};
use crate::value::{FromLua, FromLuaMulti, IntoLua, IntoLuaMulti, Value};

#[cfg(feature = "async")]
use {futures_core::future::LocalBoxFuture, futures_util::future};
use futures_util::future::{self, LocalBoxFuture};

/// An extension trait for [`AnyUserData`] that provides a variety of convenient functionality.
pub trait AnyUserDataExt<'lua>: Sealed {
Expand Down

0 comments on commit e0224ab

Please sign in to comment.