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
mpv::create_event_context returns an EventContext<'a> with the lifetime of the Mpv instance. While this works fine as long as this event context is only used in the function it is created in (such as in your examples), this makes it impossible to store the event context in a struct that also contains the Mpv instance (since you can't have a lifetime referencing something within the same struct in Rust). You also can't create a new EventContext<'a> every time you need it, since there's this atomic boolean to make sure that only once instance is ever created.
What is the reason why EventContext isn't simply held in the Mpv instance and only ever returned by reference in a getter? This way its lifetime also can never exceed the Mpv instance's lifetime, and you don't even have to do the whole atomic boolean dance.
The text was updated successfully, but these errors were encountered:
Hi,
mpv::create_event_context
returns anEventContext<'a>
with the lifetime of theMpv
instance. While this works fine as long as this event context is only used in the function it is created in (such as in your examples), this makes it impossible to store the event context in a struct that also contains theMpv
instance (since you can't have a lifetime referencing something within the same struct in Rust). You also can't create a newEventContext<'a>
every time you need it, since there's this atomic boolean to make sure that only once instance is ever created.What is the reason why
EventContext
isn't simply held in the Mpv instance and only ever returned by reference in a getter? This way its lifetime also can never exceed the Mpv instance's lifetime, and you don't even have to do the whole atomic boolean dance.The text was updated successfully, but these errors were encountered: