// This will automatically remove the event listener when `handle` is droppedlet handle = node.add_event_listener(|event: ClickEvent|{// ...});// Now it will no longer remove the event listenerstd::mem::forget(handle);

Now the event listener will remain alive forever, which is what I want.

But there's two problems with this:

I want it to keep the event listener alive forever, but I also want it to clean up any
unused internal memory. Using std::mem::forget
causes it to leak all of the memory, which is wasteful.

There are situations where I want to leak the event listener, and then later unleak it.
That's not possible with std::mem::forget.

The add_event_listener method should return DiscardOnDrop<EventListenerHandle>.

Now let's look at what is possible:

// This will automatically remove the event listener when `handle` is droppedlet handle = node.add_event_listener(|event: ClickEvent|{// ...});// Now it will no longer remove the event listener, this is similar to `std::mem::forget`let leaked =DiscardOnDrop::leak(handle);// Now it will remove the event listener, even though it was leaked
leaked.discard();