Repository: servo/servo
File: components/script/dom/toggleevent.rs (Rust)

Code before:
        bubbles: EventBubbles,
        cancelable: EventCancelable,
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
        can_gc: CanGc,
    ) -> DomRoot<ToggleEvent> {
        Self::new_with_proto(
            window, None, type_, bubbles, cancelable, old_state, new_state, source, can_gc,
        )
    }

    #[allow(clippy::too_many_arguments)]
    fn new_with_proto(
        window: &Window,
        proto: Option<HandleObject>,
        type_: Atom,
        bubbles: EventBubbles,
        cancelable: EventCancelable,
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
        can_gc: CanGc,
    ) -> DomRoot<ToggleEvent> {
        let event = Box::new(ToggleEvent::new_inherited(old_state, new_state, source));
        let ev = reflect_dom_object_with_proto(event, window, proto, can_gc);
        {
            let event = ev.upcast::<Event>();
            event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
        }
        ev
    }
}

impl ToggleEventMethods<crate::DomTypeHolder> for ToggleEvent {
    /// <https://html.spec.whatwg.org/multipage/#toggleevent>
    fn Constructor(
        window: &Window,
        proto: Option<HandleObject>,
        can_gc: CanGc,
        type_: DOMString,
        init: &ToggleEventBinding::ToggleEventInit,
    ) -> Fallible<DomRoot<ToggleEvent>> {
        let bubbles = EventBubbles::from(init.parent.bubbles);
        let cancelable = EventCancelable::from(init.parent.cancelable);
        Ok(ToggleEvent::new_with_proto(
            window,
            proto,
            Atom::from(type_),
            bubbles,
            cancelable,

Review comment (suggestion):
It's a bit confusing to have three variables, two named `event` and one named `ev` so I would either use `event` for all of them or use a different one non-abbreviated here.

```suggestion
        let event = reflect_dom_object_with_proto(event, window, proto, can_gc);
```

Code after:
        window: &Window,
        type_: Atom,
        bubbles: EventBubbles,
        cancelable: EventCancelable,
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
        can_gc: CanGc,
    ) -> DomRoot<ToggleEvent> {
        Self::new_with_proto(
            window, None, type_, bubbles, cancelable, old_state, new_state, source, can_gc,
        )
    }

    #[allow(clippy::too_many_arguments)]
    fn new_with_proto(
        window: &Window,
        proto: Option<HandleObject>,
        type_: Atom,
        bubbles: EventBubbles,
        cancelable: EventCancelable,
        old_state: DOMString,
        new_state: DOMString,
        source: Option<DomRoot<Element>>,
        can_gc: CanGc,
    ) -> DomRoot<ToggleEvent> {
        let event = Box::new(ToggleEvent::new_inherited(old_state, new_state, source));
        let event = reflect_dom_object_with_proto(event, window, proto, can_gc);
        {
            let event = event.upcast::<Event>();
            event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
        }
        event
    }
}

impl ToggleEventMethods<crate::DomTypeHolder> for ToggleEvent {
    /// <https://html.spec.whatwg.org/multipage/#toggleevent>
    fn Constructor(
        window: &Window,
        proto: Option<HandleObject>,
        can_gc: CanGc,
        type_: DOMString,
        init: &ToggleEventBinding::ToggleEventInit,
    ) -> Fallible<DomRoot<ToggleEvent>> {
        let bubbles = EventBubbles::from(init.parent.bubbles);
        let cancelable = EventCancelable::from(init.parent.cancelable);
        Ok(ToggleEvent::new_with_proto(
            window,
            proto,
            Atom::from(type_),