docs: update docs on tointegerx and tonumberx

This commit is contained in:
Nathan Craddock 2022-06-05 00:26:18 -06:00
parent f5484c6c4a
commit 5fa582d886
No known key found for this signature in database
GPG Key ID: ABE41A31B52E9DA7
2 changed files with 6 additions and 1 deletions

View File

@ -44,6 +44,10 @@ These functions have been combined into `Lua.toString()`. The function `lua_tost
The length of the returned string is almost always needed, so `Lua.toString() returns a zero-terminated Zig slice of the bytes with the correct length.
### `lua_tointegerx` and `lua_tonumberx`
Both of these functions accept an `isnum` return parameter to indicate if the conversion to number was successful. In the Zig version, both functions return either the number, or an error indicating the conversion was unsuccessful, and the `isnum` parameter is omitted.
## Examples
Here are more thorough examples that show off the ziglua bindings in context. All examples use previously documented [`build.zig`](#build-documentation) setup.

View File

@ -6,9 +6,10 @@ A Zig library that provides a lightweight wrapper around the [Lua C API](https:/
In a nutshell, ziglua is a simple wrapper around the C API you would get by using `@cImport()` to bind Lua. ziglua aims to mirror the [Lua C API](https://www.lua.org/manual/5.4/manual.html#4) as closely as possible, while improving ergonomics using Zig's features. For example:
* Zig error unions to enforce failure state handling
* Null-terminated slices instead of C strings
* Type-checked enums for parameters and return values
* Compiler-enforced checking of optional pointers
* Zig error unions to enforce error checking of failure states
* Functions return `bool` rather than `int` to indicate success
While there are a few helper functions added to complement the C API, ziglua aims to remain low-level. If you want something higher-level, perhaps try [zoltan](https://github.com/ranciere/zoltan).