summaryrefslogtreecommitdiff
path: root/docs/release_notes
diff options
context:
space:
mode:
Diffstat (limited to 'docs/release_notes')
-rw-r--r--docs/release_notes/v0.9.md24
1 files changed, 14 insertions, 10 deletions
diff --git a/docs/release_notes/v0.9.md b/docs/release_notes/v0.9.md
index 66fbc25..d735406 100644
--- a/docs/release_notes/v0.9.md
+++ b/docs/release_notes/v0.9.md
@@ -11,7 +11,7 @@ This document highlights the most important changes. For a full list of changes,
This is a long awaited feature that allows to register in Lua foreign types that cannot implement `UserData` trait because of the Rust orphan rules.
-Now you can register any type that implements `Any` trait as a userdata type.
+Now you can register any type that implements [`Any`] trait as a userdata type.
Consider the following example:
@@ -42,9 +42,10 @@ In this example we registered [`std::string::String`] as a userdata type with a
It's _not_ required to register a type before using the `Lua::create_any_userdata()` method, instead an empty metatable will be created for you.
You can also register the same type multiple times with different methods. Any previously created instances will share the old metatable, while new instances will have the new one.
-The new set of API is called `any_userdata` because it allows to register types that implements `Any` trait.
+The new set of API is called `any_userdata` because it allows to register types that implements [`Any`] trait.
[`std::string::String`]: https://doc.rust-lang.org/stable/std/string/struct.String.html
+[`Any`]: https://doc.rust-lang.org/stable/std/any/trait.Any.html
#### 2. Scope support for the new any userdata types
@@ -69,7 +70,7 @@ lua.scope(|scope| {
// This userdata instance holds only a mutable reference to our string
let ud = scope.create_any_userdata_ref_mut(&mut s)?;
lua.load(chunk! {
- $ud:replace("world", "user!")
+ $ud:replace("world", "user")
})
.exec()
})?;
@@ -78,7 +79,7 @@ lua.scope(|scope| {
println!("{s}!");
```
-#### 3. Owned types (_unstable_)
+#### 3. Owned types (`unstable`)
One of the common questions was how to embed a Lua type into Rust struct to use it later. It was non-trivial to do because of the `'lua` lifetime attached to every Lua value.
@@ -243,6 +244,11 @@ println!("{}", *ud_ref);
In the previous mlua versions the same functionality can be achieved by receiving `AnyUserData` and calling `AnyUserData::borrow()`/`AnyUserData::borrow_mut()` methods.
+The new wrappers are identical to Rust [`Ref`]/[`RefMut`] types.
+
+[`Ref`]: https://doc.rust-lang.org/std/cell/struct.Ref.html
+[`RefMut`]: https://doc.rust-lang.org/std/cell/struct.RefMut.html
+
#### New `AnyUserDataExt` trait
Similar to the `TableExt` trait, the `AnyUserDataExt` provides a set of extra methods for the `AnyUserData` type.
@@ -255,7 +261,7 @@ Similar to the `TableExt` trait, the `AnyUserDataExt` provides a set of extra me
#### Pretty formatting Lua values
-`mlua::Value` implements a new format `:#?` that allows to pretty print Lua values:
+`mlua::Value` implements a new format `:#?` that allows to (recursively) pretty print Lua values:
```rust
println!("{:#?}", lua.globals());
@@ -277,7 +283,7 @@ Prints:
}
```
-In addition a new method `Value::to_string()` was added to convert `Value` to a string (using `__tostring` metamethod if available).
+In addition a new method `Value::to_string()` has been added to convert `Value` to a string (using `__tostring` metamethod if available).
#### Environment for Lua functions
@@ -330,7 +336,7 @@ protected mode. Setting this attribute will improve performance of such operatio
#### Improved Windows target
In previous mlua versions, building a Lua module for Windows requires having Lua development libraries installed on the system.
-In contrast, on Linux and macOS, modules can be built without any external dependencies, using `-undefined=dynamic_lookup` linker flag.
+In contrast, on Linux and macOS, modules can be built without any external dependencies using the `-undefined=dynamic_lookup` linker flag.
With Rust 1.71+ it's now possible to lift this restriction for Windows as well. You can build modules normally and they will be linked with
`lua54.dll`/`lua53.dll`/`lua52.dll`/`lua51.dll` depending on the enabled Lua version.
@@ -351,9 +357,7 @@ It should be a developer decision to opt-in `FromLua` for their `T` if needed ra
To opt-in `FromLua` for `T: Clone` you can use a simple `#[derive(FromLua)]` macro (requires `feature = "macros"`):
```rust
-use mlua::FromLua;
-
-#[derive(Clone, Copy, FromLua)]
+#[derive(Clone, Copy, mlua::FromLua)]
struct MyUserData(i32);
```