mlua_derive: Update docs

This commit is contained in:
Alex Orlenko
2026-05-31 13:44:24 +01:00
parent 38c05b850e
commit 0849d05c83
3 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -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
View File
@@ -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
View File
@@ -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> {
...