You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, to provide a little more context, Rust's Index and IndexMut traits are specifically intended for container types, in which the result of the index operation already exists, so that you can return a reference to it. In your implementation of Index however, the result is created on the fly, so you can't return a reference to it. There are two solutions:
Since the indexed value already exists in memory, you could in theory return a reference to it. ValueNthElementValue() computes this reference, but it copies the referenced value to another location instead of returning a pointer. You could reimplement ValueNthElementValue(), but that would violate the Sciter source code license agreement, and the reimplementation would be susceptible to changes in the underlying data structure. So that's a no-go.
Delete the Index and IndexMut implementations and replace their uses with get(), set(), get_item(), and set_item().
There's a serious bug in the
sciter::value::Value
implementation related tostd::ops::Index
:This will print something like this, which is obviously incorrect:
The culprit is this code, which reuses the
tmp
field in a&self
method:This isn't just a bug, it's also straight up Undefined Behavior. The Clippy
mut_from_ref
lint is there for a reason...The text was updated successfully, but these errors were encountered: