mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
mlua_derive: Update docs
This commit is contained in:
+3
-3
@@ -8,7 +8,7 @@ Named fields are exposed as readable and writable fields in Lua by default.
|
||||
Use `#[lua(...)]` on individual fields or methods to control how they are
|
||||
registered.
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
use mlua::{Lua, Result, UserData};
|
||||
|
||||
#[derive(UserData)]
|
||||
@@ -92,7 +92,7 @@ At most one of `getter`, `setter`, `field` may be specified on a method.
|
||||
Constants in an `#[mlua::userdata_impl]` block are registered as static
|
||||
fields:
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
#[mlua::userdata_impl]
|
||||
impl MyType {
|
||||
const VERSION: &str = "1.0";
|
||||
@@ -108,7 +108,7 @@ Annotate a method with `#[lua(meta)]` to register it as a Lua metamethod.
|
||||
The metamethod name is inferred from the function name when it starts with
|
||||
`__`. Use `name = "..."` to specify the name explicitly.
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
#[mlua::userdata_impl]
|
||||
impl MyType {
|
||||
#[lua(meta, infallible)]
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ User's Rust types needs to implement [`UserData`] or [`IntoLua`] traits.
|
||||
|
||||
Captured variables are **moved** into the chunk.
|
||||
|
||||
```
|
||||
```rust
|
||||
use mlua::{Lua, Result, chunk};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ Registers Lua module entrypoint.
|
||||
|
||||
You can register multiple entrypoints as required.
|
||||
|
||||
```ignore
|
||||
```rust,ignore
|
||||
use mlua::{Lua, Result, Table};
|
||||
|
||||
#[mlua::lua_module]
|
||||
@@ -19,7 +19,7 @@ You can also pass options to the attribute:
|
||||
|
||||
* name - name of the module, defaults to the name of the function
|
||||
|
||||
```ignore
|
||||
```rust,ignore
|
||||
#[mlua::lua_module(name = "alt_module")]
|
||||
fn my_module(lua: &Lua) -> Result<Table> {
|
||||
...
|
||||
@@ -33,7 +33,7 @@ limits or not. As a result, some operations that require memory allocation run i
|
||||
mode. Setting this attribute will improve performance of such operations with risk of having
|
||||
uncaught exceptions and memory leaks.
|
||||
|
||||
```ignore
|
||||
```rust,ignore
|
||||
#[mlua::lua_module(skip_memory_check)]
|
||||
fn my_module(lua: &Lua) -> Result<Table> {
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user