Skip to content

Commit b5a4c84

Browse files
committed
Make function module public
Reduce number of function-specific types exported to the mlua root and keep them inside the inner module.
1 parent 613748e commit b5a4c84

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/function.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Lua function handling.
2+
//!
3+
//! This module contains the [`Function`] type, which represents a handle to a Lua function,
4+
//! along with associated methods for calling Lua functions, retrieving function information,
5+
//! and manipulating function environments.
6+
17
use std::cell::RefCell;
28
use std::os::raw::{c_int, c_void};
39
use std::{mem, ptr, slice};
@@ -681,7 +687,9 @@ impl LuaType for Function {
681687
const TYPE_ID: c_int = ffi::LUA_TFUNCTION;
682688
}
683689

690+
/// Future for asynchronous function calls.
684691
#[cfg(feature = "async")]
692+
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
685693
#[must_use = "futures do nothing unless you `.await` or poll them"]
686694
pub struct AsyncCallFuture<R: FromLuaMulti>(Result<AsyncThread<R>>);
687695

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ mod chunk;
7676
mod conversion;
7777
mod debug;
7878
mod error;
79-
mod function;
8079
#[cfg(any(feature = "luau", doc))]
8180
mod luau;
8281
mod memory;
@@ -94,6 +93,7 @@ mod util;
9493
mod value;
9594
mod vector;
9695

96+
pub mod function;
9797
pub mod prelude;
9898

9999
pub use bstr::BString;
@@ -102,7 +102,7 @@ pub use ffi::{self, lua_CFunction, lua_State};
102102
pub use crate::chunk::{AsChunk, Chunk, ChunkMode};
103103
pub use crate::debug::{Debug, DebugEvent, DebugNames, DebugSource, DebugStack};
104104
pub use crate::error::{Error, ErrorContext, ExternalError, ExternalResult, Result};
105-
pub use crate::function::{Function, FunctionInfo};
105+
pub use crate::function::Function;
106106
pub use crate::multi::{MultiValue, Variadic};
107107
pub use crate::scope::Scope;
108108
pub use crate::state::{GCMode, Lua, LuaOptions, WeakLua};
@@ -130,7 +130,6 @@ pub use crate::debug::HookTriggers;
130130
pub use crate::{
131131
buffer::Buffer,
132132
chunk::{CompileConstant, Compiler},
133-
function::CoverageInfo,
134133
luau::{HeapDump, NavigateError, Require, TextRequirer},
135134
vector::Vector,
136135
};

src/prelude.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ pub use crate::{
55
AnyUserData as LuaAnyUserData, BorrowedBytes as LuaBorrowedBytes, BorrowedStr as LuaBorrowedStr,
66
Chunk as LuaChunk, Either as LuaEither, Error as LuaError, ErrorContext as LuaErrorContext,
77
ExternalError as LuaExternalError, ExternalResult as LuaExternalResult, FromLua, FromLuaMulti,
8-
Function as LuaFunction, FunctionInfo as LuaFunctionInfo, GCMode as LuaGCMode, Integer as LuaInteger,
9-
IntoLua, IntoLuaMulti, LightUserData as LuaLightUserData, Lua, LuaNativeFn, LuaNativeFnMut, LuaOptions,
10-
LuaString, MetaMethod as LuaMetaMethod, MultiValue as LuaMultiValue, Nil as LuaNil, Number as LuaNumber,
8+
Function as LuaFunction, GCMode as LuaGCMode, Integer as LuaInteger, IntoLua, IntoLuaMulti,
9+
LightUserData as LuaLightUserData, Lua, LuaNativeFn, LuaNativeFnMut, LuaOptions, LuaString,
10+
MetaMethod as LuaMetaMethod, MultiValue as LuaMultiValue, Nil as LuaNil, Number as LuaNumber,
1111
ObjectLike as LuaObjectLike, RegistryKey as LuaRegistryKey, Result as LuaResult, StdLib as LuaStdLib,
1212
Table as LuaTable, TablePairs as LuaTablePairs, TableSequence as LuaTableSequence, Thread as LuaThread,
1313
ThreadStatus as LuaThreadStatus, UserData as LuaUserData, UserDataFields as LuaUserDataFields,
@@ -24,9 +24,8 @@ pub use crate::HookTriggers as LuaHookTriggers;
2424
#[cfg(feature = "luau")]
2525
#[doc(no_inline)]
2626
pub use crate::{
27-
CompileConstant as LuaCompileConstant, CoverageInfo as LuaCoverageInfo,
28-
NavigateError as LuaNavigateError, Require as LuaRequire, TextRequirer as LuaTextRequirer,
29-
Vector as LuaVector,
27+
CompileConstant as LuaCompileConstant, NavigateError as LuaNavigateError, Require as LuaRequire,
28+
TextRequirer as LuaTextRequirer, Vector as LuaVector,
3029
};
3130

3231
#[cfg(feature = "async")]

tests/function.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn test_function_coverage() -> Result<()> {
267267

268268
assert_eq!(
269269
report[0],
270-
mlua::CoverageInfo {
270+
mlua::function::CoverageInfo {
271271
function: None,
272272
line_defined: 1,
273273
depth: 0,
@@ -276,7 +276,7 @@ fn test_function_coverage() -> Result<()> {
276276
);
277277
assert_eq!(
278278
report[1],
279-
mlua::CoverageInfo {
279+
mlua::function::CoverageInfo {
280280
function: Some("abc".into()),
281281
line_defined: 4,
282282
depth: 1,
@@ -285,7 +285,7 @@ fn test_function_coverage() -> Result<()> {
285285
);
286286
assert_eq!(
287287
report[2],
288-
mlua::CoverageInfo {
288+
mlua::function::CoverageInfo {
289289
function: None,
290290
line_defined: 12,
291291
depth: 1,
@@ -294,7 +294,7 @@ fn test_function_coverage() -> Result<()> {
294294
);
295295
assert_eq!(
296296
report[3],
297-
mlua::CoverageInfo {
297+
mlua::function::CoverageInfo {
298298
function: None,
299299
line_defined: 13,
300300
depth: 2,

0 commit comments

Comments
 (0)