Repository: lapce/lapce
File: lapce-ui/src/tab.rs (Rust)

Code before:
                        if let Some(elem) = plugin.installing.get_mut(&volt.id()) {
                            if !error.is_empty() {
                                elem.set_error(error);
                            }
                        } else {
                            plugin.installing.insert(
                                volt.id(),
                                PluginInstallStatus::new(
                                    PluginInstallType::UNINSTALLATION,
                                    &volt.display_name,
                                    error.to_string(),
                                ),
                            );
                        }
                    }
                    LapceUICommand::VoltRemoved(volt, only_installing) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        let id = volt.id();

                        // if there is a value inside the installing map, remove it from there as soon as it is installed.
                        plugin.installing.remove(&volt.id());

                        if !(*only_installing) {
                            plugin.installed.remove(&id);

                            if plugin.disabled.contains(&id) {
                                plugin.disabled.remove(&id);
                                let _ = data.db.save_disabled_volts(
                                    plugin.disabled.iter().collect(),
                                );
                            }
                            if plugin.workspace_disabled.contains(&id) {
                                plugin.workspace_disabled.remove(&id);
                                let _ = data.db.save_disabled_volts(
                                    plugin.workspace_disabled.iter().collect(),
                                );
                            }
                        }
                    }
                    LapceUICommand::DisableVoltWorkspace(volt) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.workspace_disabled.insert(volt.id());
                        data.proxy.proxy_rpc.disable_volt(volt.clone());
                        let _ = data.db.save_workspace_disabled_volts(
                            &data.workspace,
                            plugin.workspace_disabled.iter().collect(),
                        );
                    }
                    LapceUICommand::EnableVoltWorkspace(volt) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        let id = volt.id();

Review comment (suggestion):
You don't need the `contains` check. [remove](https://doc.rust-lang.org/std/collections/struct.HashSet.html#method.remove) will tell you if the element was present

Code after:
                            if !error.is_empty() {
                                elem.set_error(error);
                            }
                        } else {
                            plugin.installing.insert(
                                volt.id(),
                                PluginInstallStatus::new(
                                    PluginInstallType::Uninstallation,
                                    &volt.display_name,
                                    error.to_string(),
                                ),
                            );
                        }
                    }
                    LapceUICommand::VoltRemoved(volt, only_installing) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        let id = volt.id();

                        // if there is a value inside the installing map, remove it from there as soon as it is installed.
                        plugin.installing.remove(&volt.id());

                        if !(*only_installing) {
                            plugin.installed.remove(&id);

                            if plugin.disabled.remove(&id) {
                                let _ = data.db.save_disabled_volts(
                                    plugin.disabled.iter().collect(),
                                );
                            }
                            if plugin.workspace_disabled.remove(&id) {
                                let _ = data.db.save_disabled_volts(
                                    plugin.workspace_disabled.iter().collect(),
                                );
                            }
                        }
                    }
                    LapceUICommand::DisableVoltWorkspace(volt) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        plugin.workspace_disabled.insert(volt.id());
                        data.proxy.proxy_rpc.disable_volt(volt.clone());
                        let _ = data.db.save_workspace_disabled_volts(
                            &data.workspace,
                            plugin.workspace_disabled.iter().collect(),
                        );
                    }
                    LapceUICommand::EnableVoltWorkspace(volt) => {
                        let plugin = Arc::make_mut(&mut data.plugin);
                        let id = volt.id();
                        plugin.workspace_disabled.remove(&id);
                        if !plugin.plugin_disabled(&id) {
                            data.proxy.proxy_rpc.enable_volt(volt.clone());