pub struct AnyUserData<'lua>(_);
Handle to an internal Lua userdata for any type that implements UserData
.
Similar to std::any::Any
, this provides an interface for dynamic type checking via the is
and borrow
methods.
Internally, instances are stored in a RefCell
, to best match the mutable semantics of the Lua
language.
This API should only be used when necessary. Implementing UserData
already allows defining
methods which check the type and acquire a borrow behind the scenes.
Checks whether the type of this userdata is T
.
Borrow this userdata immutably if it is of type T
.
Returns a UserDataBorrowError
if the userdata is already mutably borrowed. Returns a
UserDataTypeMismatch
if the userdata is not of type T
.
Borrow this userdata mutably if it is of type T
.
Returns a UserDataBorrowMutError
if the userdata is already borrowed. Returns a
UserDataTypeMismatch
if the userdata is not of type T
.
Sets an associated value to this AnyUserData
.
The value may be any Lua value whatsoever, and can be retrieved with get_user_value
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static