removes unneeded borrows (#212)

This commit is contained in:
legendofmiracles 2021-07-15 13:38:28 +02:00 committed by GitHub
parent 31730bea32
commit 9e00f8f154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 15 deletions

View File

@ -204,7 +204,7 @@ impl App {
}
fn close_window(&mut self, window_name: &WindowName) -> Result<()> {
for unused_var in self.variables_only_used_in(&window_name) {
for unused_var in self.variables_only_used_in(window_name) {
log::info!("stopping for {}", &unused_var);
self.script_var_handler.stop_for_variable(unused_var.clone());
}
@ -246,7 +246,7 @@ impl App {
// initialize script var handlers for variables that where not used before opening this window.
// TODO somehow make this less shit
for newly_used_var in
self.variables_only_used_in(&window_name).filter_map(|var| self.eww_config.get_script_var(&var).ok())
self.variables_only_used_in(window_name).filter_map(|var| self.eww_config.get_script_var(var).ok())
{
self.script_var_handler.add(newly_used_var.clone());
}

View File

@ -11,14 +11,14 @@ lazy_static::lazy_static! {
/// Notify all listening tasks of the termination of the eww application process.
pub fn send_exit() -> Result<()> {
(&*APPLICATION_EXIT_SENDER).send(()).context("Failed to send exit lifecycle event")?;
(APPLICATION_EXIT_SENDER).send(()).context("Failed to send exit lifecycle event")?;
Ok(())
}
/// Yields Ok(()) on application termination. Await on this in all long-running tasks
/// and perform any cleanup if necessary.
pub async fn recv_exit() -> Result<()> {
(&*APPLICATION_EXIT_SENDER).subscribe().recv().await.context("Failed to receive lifecycle event")
(APPLICATION_EXIT_SENDER).subscribe().recv().await.context("Failed to receive lifecycle event")
}
/// Select in a loop, breaking once a application termination event (see `crate::application_lifecycle`) is received.

View File

@ -77,7 +77,7 @@ impl WidgetUse {
.map(|attr| {
(
AttrName(attr.name().to_owned()),
AttrVal::parse_string(&xml_ext::resolve_escaped_symbols(&attr.value())),
AttrVal::parse_string(&xml_ext::resolve_escaped_symbols(attr.value())),
)
})
.collect::<HashMap<_, _>>(),

View File

@ -52,7 +52,7 @@ impl ScriptVar {
ScriptVar::Poll(x) => match &x.command {
VarSource::Function(f) => f().with_context(|| format!("Failed to compute initial value for {}", &self.name())),
VarSource::Shell(f) => {
run_command(&f).with_context(|| format!("Failed to compute initial value for {}", &self.name()))
run_command(f).with_context(|| format!("Failed to compute initial value for {}", &self.name()))
}
},
ScriptVar::Tail(_) => Ok(PrimVal::from_string(String::new())),

View File

@ -102,7 +102,7 @@ pub fn join_path_pretty<P: AsRef<std::path::Path>, P2: AsRef<std::path::Path>>(a
if b.is_absolute() {
b.to_path_buf()
} else {
a.parent().unwrap().join(b.strip_prefix("./").unwrap_or(&b))
a.parent().unwrap().join(b.strip_prefix("./").unwrap_or(b))
}
}

View File

@ -160,14 +160,14 @@ impl AttrValElement {
pub fn as_expr(&self) -> Option<&AttrValExpr> {
match self {
AttrValElement::Expr(x) => Some(&x),
AttrValElement::Expr(x) => Some(x),
_ => None,
}
}
pub fn as_primitive(&self) -> Option<&PrimVal> {
match self {
AttrValElement::Primitive(x) => Some(&x),
AttrValElement::Primitive(x) => Some(x),
_ => None,
}
}

View File

@ -143,7 +143,7 @@ impl AttrValExpr {
pub fn eval(self, values: &HashMap<VarName, PrimVal>) -> Result<PrimVal> {
match self {
AttrValExpr::Literal(x) => x.resolve_fully(&values),
AttrValExpr::Literal(x) => x.resolve_fully(values),
AttrValExpr::VarRef(ref name) => values
.get(name)
.cloned()

View File

@ -82,7 +82,7 @@ fn build_builtin_gtk_widget(
// run resolve functions for superclasses such as range, orientable, and widget
if let Some(gtk_widget) = gtk_widget.dynamic_cast_ref::<gtk::Container>() {
resolve_container_attrs(&mut bargs, &gtk_widget);
resolve_container_attrs(&mut bargs, gtk_widget);
for child in &widget.children {
let child_widget = child.render(bargs.eww_state, window_name, widget_definitions).with_context(|| {
format!(
@ -98,10 +98,10 @@ fn build_builtin_gtk_widget(
}
if let Some(w) = gtk_widget.dynamic_cast_ref() {
resolve_range_attrs(&mut bargs, &w)
resolve_range_attrs(&mut bargs, w)
}
if let Some(w) = gtk_widget.dynamic_cast_ref() {
resolve_orientable_attrs(&mut bargs, &w)
resolve_orientable_attrs(&mut bargs, w)
};
resolve_widget_attrs(&mut bargs, &gtk_widget);

View File

@ -608,7 +608,7 @@ fn connect_first_map<W: IsA<gtk::Widget>, F: Fn(&W) + 'static>(widget: &W, func:
let is_first_map = std::rc::Rc::new(std::cell::RefCell::new(true));
widget.connect_map(move |w| {
if is_first_map.replace(false) {
func(&w);
func(w);
}
});
}

View File

@ -91,7 +91,7 @@ impl WidgetNode for Generic {
window_name: &WindowName,
widget_definitions: &HashMap<String, WidgetDefinition>,
) -> Result<gtk::Widget> {
crate::widgets::build_builtin_gtk_widget(eww_state, window_name, widget_definitions, &self)?
crate::widgets::build_builtin_gtk_widget(eww_state, window_name, widget_definitions, self)?
.with_context(|| format!("Unknown widget '{}'", self.get_name()))
}
}