diff --git a/crates/eww/src/app.rs b/crates/eww/src/app.rs index 6c9d051..bece5a8 100644 --- a/crates/eww/src/app.rs +++ b/crates/eww/src/app.rs @@ -7,6 +7,7 @@ use crate::{ state::scope_graph::{ScopeGraph, ScopeGraphEvent, ScopeIndex}, EwwPaths, *, }; +use anyhow::anyhow; use eww_shared_util::VarName; use itertools::Itertools; use simplexpr::dynval::DynVal; diff --git a/crates/eww/src/application_lifecycle.rs b/crates/eww/src/application_lifecycle.rs index 8a5cd3c..e97129a 100644 --- a/crates/eww/src/application_lifecycle.rs +++ b/crates/eww/src/application_lifecycle.rs @@ -2,7 +2,7 @@ //! Currently, this only means handling application exit by providing a global //! `recv_exit()` function which can be awaited to receive an event in case of application termination. -use anyhow::*; +use anyhow::{Context, Result}; use once_cell::sync::Lazy; use tokio::sync::broadcast; diff --git a/crates/eww/src/client.rs b/crates/eww/src/client.rs index 61ac5a2..023dfaa 100644 --- a/crates/eww/src/client.rs +++ b/crates/eww/src/client.rs @@ -5,7 +5,7 @@ use crate::{ opts::{self, ActionClientOnly}, EwwPaths, }; -use anyhow::*; +use anyhow::{Context, Result}; use std::{ io::{Read, Write}, os::unix::net::UnixStream, @@ -24,7 +24,6 @@ pub fn handle_client_only_action(paths: &EwwPaths, action: ActionClientOnly) -> Ok(()) } - /// Connect to the daemon and send the given request. /// Returns the response from the daemon, or None if the daemon did not provide any useful response. An Ok(None) response does _not_ indicate failure. pub fn do_server_call(stream: &mut UnixStream, action: &opts::ActionWithServer) -> Result> { diff --git a/crates/eww/src/config/eww_config.rs b/crates/eww/src/config/eww_config.rs index 33d0b04..71b9ea1 100644 --- a/crates/eww/src/config/eww_config.rs +++ b/crates/eww/src/config/eww_config.rs @@ -1,4 +1,4 @@ -use anyhow::*; +use anyhow::{bail, Context, Result}; use eww_shared_util::VarName; use std::{collections::HashMap, path::Path}; use yuck::config::{ diff --git a/crates/eww/src/config/script_var.rs b/crates/eww/src/config/script_var.rs index 9e4c424..db5dacd 100644 --- a/crates/eww/src/config/script_var.rs +++ b/crates/eww/src/config/script_var.rs @@ -1,6 +1,6 @@ use std::process::Command; -use anyhow::*; +use anyhow::{anyhow, bail, Context, Result}; use codespan_reporting::diagnostic::Severity; use eww_shared_util::{Span, VarName}; use simplexpr::dynval::DynVal; diff --git a/crates/eww/src/config/system_stats.rs b/crates/eww/src/config/system_stats.rs index fd322a5..438c732 100644 --- a/crates/eww/src/config/system_stats.rs +++ b/crates/eww/src/config/system_stats.rs @@ -1,5 +1,5 @@ use crate::util::IterAverage; -use anyhow::*; +use anyhow::{Context, Result}; use itertools::Itertools; use once_cell::sync::Lazy; use std::{fs::read_to_string, sync::Mutex}; diff --git a/crates/eww/src/config/window_definition.rs b/crates/eww/src/config/window_definition.rs index e69de29..8b13789 100644 --- a/crates/eww/src/config/window_definition.rs +++ b/crates/eww/src/config/window_definition.rs @@ -0,0 +1 @@ + diff --git a/crates/eww/src/daemon_response.rs b/crates/eww/src/daemon_response.rs index 35fb7ed..c4fce94 100644 --- a/crates/eww/src/daemon_response.rs +++ b/crates/eww/src/daemon_response.rs @@ -1,4 +1,4 @@ -use anyhow::*; +use anyhow::{Context, Result}; use itertools::Itertools; use crate::error_handling_ctx; diff --git a/crates/eww/src/display_backend.rs b/crates/eww/src/display_backend.rs index 9806450..bbd2c0f 100644 --- a/crates/eww/src/display_backend.rs +++ b/crates/eww/src/display_backend.rs @@ -13,7 +13,10 @@ mod platform { mod platform { use gdk; use gtk::prelude::*; - use yuck::config::{window_definition::{WindowStacking, WindowDefinition}, window_geometry::AnchorAlignment}; + use yuck::config::{ + window_definition::{WindowDefinition, WindowStacking}, + window_geometry::AnchorAlignment, + }; pub fn initialize_window(window_def: &WindowDefinition, monitor: gdk::Rectangle) -> Option { let window = gtk::Window::new(gtk::WindowType::Toplevel); @@ -89,7 +92,7 @@ mod platform { #[cfg(feature = "x11")] mod platform { - use anyhow::*; + use anyhow::{Context, Result}; use gdkx11; use gtk::{self, prelude::*}; use x11rb::protocol::xproto::ConnectionExt; diff --git a/crates/eww/src/ipc_server.rs b/crates/eww/src/ipc_server.rs index e020b0c..7630f00 100644 --- a/crates/eww/src/ipc_server.rs +++ b/crates/eww/src/ipc_server.rs @@ -1,5 +1,5 @@ use crate::{app, opts}; -use anyhow::*; +use anyhow::{Context, Result}; use std::time::Duration; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, diff --git a/crates/eww/src/main.rs b/crates/eww/src/main.rs index bbe9a38..f1290c3 100644 --- a/crates/eww/src/main.rs +++ b/crates/eww/src/main.rs @@ -13,7 +13,7 @@ extern crate gtk; #[cfg(feature = "wayland")] extern crate gtk_layer_shell as gtk_layer_shell; -use anyhow::*; +use anyhow::{bail, Context, Result}; use daemon_response::{DaemonResponse, DaemonResponseReceiver}; use opts::ActionWithServer; use std::{ diff --git a/crates/eww/src/opts.rs b/crates/eww/src/opts.rs index b4e0061..8bef97b 100644 --- a/crates/eww/src/opts.rs +++ b/crates/eww/src/opts.rs @@ -1,4 +1,4 @@ -use anyhow::*; +use anyhow::{Context, Result}; use eww_shared_util::VarName; use serde::{Deserialize, Serialize}; use simplexpr::dynval::DynVal; diff --git a/crates/eww/src/script_var_handler.rs b/crates/eww/src/script_var_handler.rs index edcc0c1..b78f4a8 100644 --- a/crates/eww/src/script_var_handler.rs +++ b/crates/eww/src/script_var_handler.rs @@ -4,7 +4,7 @@ use crate::{ app, config::{create_script_var_failed_warn, script_var}, }; -use anyhow::*; +use anyhow::{anyhow, Result}; use app::DaemonCommand; use eww_shared_util::VarName; diff --git a/crates/eww/src/server.rs b/crates/eww/src/server.rs index 6c3817f..de2006c 100644 --- a/crates/eww/src/server.rs +++ b/crates/eww/src/server.rs @@ -4,9 +4,16 @@ use crate::{ state::scope_graph::ScopeGraph, util, EwwPaths, }; -use anyhow::*; +use anyhow::{Context, Result}; -use std::{cell::RefCell, collections::{HashMap, HashSet}, os::unix::io::AsRawFd, path::Path, rc::Rc, sync::{atomic::Ordering, Arc}}; +use std::{ + cell::RefCell, + collections::{HashMap, HashSet}, + os::unix::io::AsRawFd, + path::Path, + rc::Rc, + sync::{atomic::Ordering, Arc}, +}; use tokio::sync::mpsc::*; pub fn initialize_server(paths: EwwPaths, action: Option, should_daemonize: bool) -> Result { diff --git a/crates/eww/src/state/one_to_n_elements_map.rs b/crates/eww/src/state/one_to_n_elements_map.rs index 11a755f..91834e0 100644 --- a/crates/eww/src/state/one_to_n_elements_map.rs +++ b/crates/eww/src/state/one_to_n_elements_map.rs @@ -1,4 +1,4 @@ -use anyhow::*; +use anyhow::{bail, Result}; use std::collections::{HashMap, HashSet}; /// A map that represents a structure of a 1-n relationship with edges that contain data. @@ -83,7 +83,11 @@ impl OneToNElemen ); } } else { - bail!("parent_to_child stored mapping from {:?} to {:?}, which was not found in child_to_parent", parent, child); + bail!( + "parent_to_child stored mapping from {:?} to {:?}, which was not found in child_to_parent", + parent, + child + ); } } } @@ -109,7 +113,6 @@ mod test { assert_eq!(map.get_parent_of(4), None); assert_eq!(map.get_parent_of(5), Some(4)); - assert_eq!(map.get_children_of(4), HashSet::from_iter(vec![3, 5])); assert_eq!(map.get_children_of(3), HashSet::from_iter(vec![2])); assert_eq!(map.get_children_of(2), HashSet::from_iter(vec![1])); @@ -135,6 +138,5 @@ mod test { assert_eq!(map.get_children_of(3), HashSet::from_iter(vec![2])); assert_eq!(map.get_children_of(2), HashSet::from_iter(vec![1])); assert_eq!(map.get_children_of(1), HashSet::new()); - } } diff --git a/crates/eww/src/state/scope_graph.rs b/crates/eww/src/state/scope_graph.rs index 310ec1e..052a1c4 100644 --- a/crates/eww/src/state/scope_graph.rs +++ b/crates/eww/src/state/scope_graph.rs @@ -3,7 +3,7 @@ use std::{ rc::Rc, }; -use anyhow::*; +use anyhow::{anyhow, bail, Context, Result}; use eww_shared_util::{AttrName, VarName}; use simplexpr::{dynval::DynVal, SimplExpr}; use tokio::sync::mpsc::UnboundedSender; diff --git a/crates/eww/src/util.rs b/crates/eww/src/util.rs index a15190e..c525648 100644 --- a/crates/eww/src/util.rs +++ b/crates/eww/src/util.rs @@ -1,8 +1,7 @@ -use anyhow::*; -use std::fmt::Write; +use anyhow::{anyhow, Context, Result}; use extend::ext; use itertools::Itertools; -use std::path::Path; +use std::{fmt::Write, path::Path}; #[macro_export] macro_rules! try_logging_errors { @@ -160,10 +159,13 @@ pub fn unindent(text: &str) -> String { // take all the lines of our text and skip over the first empty ones let lines = text.lines().skip_while(|x| *x == ""); // find the smallest indentation - let min = lines.clone().fold(None, |min, line| { - let min = min.unwrap_or(usize::MAX); - Some(min.min(line.chars().take(min).take_while(|&c| c == ' ').count())) - }).unwrap_or(0); + let min = lines + .clone() + .fold(None, |min, line| { + let min = min.unwrap_or(usize::MAX); + Some(min.min(line.chars().take(min).take_while(|&c| c == ' ').count())) + }) + .unwrap_or(0); let mut result = String::new(); for i in lines { diff --git a/crates/eww/src/widgets/build_widget.rs b/crates/eww/src/widgets/build_widget.rs index 39c7e7f..7a71d4c 100644 --- a/crates/eww/src/widgets/build_widget.rs +++ b/crates/eww/src/widgets/build_widget.rs @@ -1,4 +1,4 @@ -use anyhow::*; +use anyhow::{Context, Result}; use codespan_reporting::diagnostic::Severity; use eww_shared_util::AttrName; use gdk::prelude::Cast; diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index 1348bd6..8f8db3d 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -1,9 +1,13 @@ #![allow(clippy::option_map_unit_fn)] use super::{build_widget::BuilderArgs, circular_progressbar::*, run_command}; use crate::{ - def_widget, enum_parse, error::DiagError, error_handling_ctx, util::{list_difference, unindent}, widgets::build_widget::build_gtk_widget, + def_widget, enum_parse, + error::DiagError, + error_handling_ctx, + util::{list_difference, unindent}, + widgets::build_widget::build_gtk_widget, }; -use anyhow::*; +use anyhow::{anyhow, Context, Result}; use codespan_reporting::diagnostic::Severity; use eww_shared_util::Spanned; use gdk::NotifyType; diff --git a/crates/simplexpr/src/eval.rs b/crates/simplexpr/src/eval.rs index 769bb93..a3f1789 100644 --- a/crates/simplexpr/src/eval.rs +++ b/crates/simplexpr/src/eval.rs @@ -135,7 +135,9 @@ impl SimplExpr { } FunctionCall(_, _, args) => args.iter().flat_map(|a| a.var_refs_with_span()).collect(), JsonArray(_, values) => values.iter().flat_map(|v| v.var_refs_with_span()).collect(), - JsonObject(_, entries) => entries.iter().flat_map(|(k, v)| k.var_refs_with_span().into_iter().chain(v.var_refs_with_span())).collect(), + JsonObject(_, entries) => { + entries.iter().flat_map(|(k, v)| k.var_refs_with_span().into_iter().chain(v.var_refs_with_span())).collect() + } } } diff --git a/crates/yuck/src/config/backend_window_options.rs b/crates/yuck/src/config/backend_window_options.rs index 46eedfa..85d233c 100644 --- a/crates/yuck/src/config/backend_window_options.rs +++ b/crates/yuck/src/config/backend_window_options.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anyhow::*; +use anyhow::{anyhow, Result}; use crate::{ enum_parse,