Repository: servo/servo
File: components/devtools/actors/console.rs (Rust)

Code before:
struct SetPreferencesReply {
    from: String,
    updated: Vec<String>,
}

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct PageErrorWrapper {
    page_error: PageError,
}

pub(crate) enum Root {
    BrowsingContext(String),
    DedicatedWorker(String),
}

pub(crate) struct ConsoleActor {
    pub name: String,
    pub root: Root,
    pub cached_events: AtomicRefCell<HashMap<UniqueId, Vec<CachedConsoleMessage>>>,
}

impl ConsoleActor {
    fn script_chan(&self, registry: &ActorRegistry) -> GenericSender<DevtoolScriptControlMsg> {
        match &self.root {
            Root::BrowsingContext(bc) => registry
                .find::<BrowsingContextActor>(bc)
                .script_chan
                .clone(),
            Root::DedicatedWorker(worker) => {
                registry.find::<WorkerActor>(worker).script_chan.clone()
            },
        }
    }

    fn current_unique_id(&self, registry: &ActorRegistry) -> UniqueId {
        match &self.root {
            Root::BrowsingContext(bc) => {
                UniqueId::Pipeline(registry.find::<BrowsingContextActor>(bc).pipeline_id())
            },
            Root::DedicatedWorker(w) => UniqueId::Worker(registry.find::<WorkerActor>(w).worker_id),
        }
    }

    fn evaluate_js(
        &self,
        registry: &ActorRegistry,
        msg: &Map<String, Value>,
    ) -> Result<EvaluateJSReply, ()> {
        let input = msg.get("text").unwrap().as_str().unwrap().to_owned();
        let (chan, port) = generic_channel::channel().unwrap();

Review comment (suggestion):
Nit:

```suggestion
            Root::BrowsingContext(browsing_context) => registry
```

Code after:
struct SetPreferencesReply {
    from: String,
    updated: Vec<String>,
}

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct PageErrorWrapper {
    page_error: PageError,
}

pub(crate) enum Root {
    BrowsingContext(String),
    DedicatedWorker(String),
}

pub(crate) struct ConsoleActor {
    pub name: String,
    pub root: Root,
    pub cached_events: AtomicRefCell<HashMap<UniqueId, Vec<CachedConsoleMessage>>>,
}

impl ConsoleActor {
    fn script_chan(&self, registry: &ActorRegistry) -> GenericSender<DevtoolScriptControlMsg> {
        match &self.root {
            Root::BrowsingContext(browsing_context) => registry
                .find::<BrowsingContextActor>(browsing_context)
                .script_chan
                .clone(),
            Root::DedicatedWorker(worker) => {
                registry.find::<WorkerActor>(worker).script_chan.clone()
            },
        }
    }

    fn current_unique_id(&self, registry: &ActorRegistry) -> UniqueId {
        match &self.root {
            Root::BrowsingContext(browsing_context) => UniqueId::Pipeline(
                registry
                    .find::<BrowsingContextActor>(browsing_context)
                    .pipeline_id(),
            ),
            Root::DedicatedWorker(worker) => {
                UniqueId::Worker(registry.find::<WorkerActor>(worker).worker_id)
            },
        }
    }

    fn evaluate_js(
        &self,
        registry: &ActorRegistry,