Fix a few clippy warnings (#59)

This commit is contained in:
ay9thqi3tbqiwbegqsg a[soiaosshasdg 2020-11-14 16:57:50 +00:00 committed by GitHub
parent 2e8b1af083
commit ac8bc7d8b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 36 additions and 46 deletions

View file

@ -7,7 +7,6 @@ use crate::{
widgets,
};
use anyhow::*;
use crossbeam_channel;
use debug_stub_derive::*;
use gdk::WindowExt;
use gtk::{ContainerExt, CssProviderExt, GtkWindowExt, StyleContextExt, WidgetExt};

View file

@ -86,7 +86,7 @@ impl<'a, 'b> XmlNode<'a, 'b> {
match self {
XmlNode::Text(x) => x.0,
XmlNode::Element(x) => x.0,
XmlNode::Ignored(x) => x.clone(),
XmlNode::Ignored(x) => *x,
}
}
}
@ -123,7 +123,7 @@ impl<'a, 'b> fmt::Display for XmlElement<'a, 'b> {
.map(|x| x.lines().map(|line| format!(" {}", line)).join("\n"))
.join("\n");
if children.len() == 0 {
if children.is_empty() {
write!(f, "{}</{}>", self.as_tag_string(), self.tag_name())
} else {
write!(f, "{}\n{}\n</{}>", self.as_tag_string(), children, self.tag_name())

View file

@ -10,8 +10,6 @@ extern crate gtk;
use anyhow::*;
use log;
use pretty_env_logger;
use std::{os::unix::net, path::PathBuf};
use structopt::StructOpt;
@ -33,12 +31,12 @@ lazy_static::lazy_static! {
.join("eww-server");
pub static ref CONFIG_DIR: std::path::PathBuf = std::env::var("XDG_CONFIG_HOME")
.map(|v| PathBuf::from(v))
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".config"))
.join("eww");
pub static ref LOG_FILE: std::path::PathBuf = std::env::var("XDG_CACHE_HOME")
.map(|v| PathBuf::from(v))
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".cache"))
.join("eww.log");
}
@ -56,17 +54,17 @@ fn main() {
opts::Action::WithServer(action) => {
log::info!("Trying to find server process");
if let Ok(stream) = net::UnixStream::connect(&*IPC_SOCKET_PATH) {
client::forward_command_to_server(stream, action).context("Error while forwarding command to server")?;
} else {
if action.needs_server_running() {
} else if action.needs_server_running() {
println!("No eww server running");
} else {
log::info!("No server running, initializing server...");
server::initialize_server(opts.should_detach, action)?;
}
}
}
}
};
if let Err(e) = result {

View file

@ -93,9 +93,7 @@ fn parse_var_update_arg(s: &str) -> Result<(VarName, PrimitiveValue)> {
impl ActionWithServer {
pub fn into_eww_command(self) -> (app::EwwCommand, Option<crossbeam_channel::Receiver<String>>) {
let command = match self {
ActionWithServer::Update { mappings } => {
app::EwwCommand::UpdateVars(mappings.into_iter().map(|x| x.into()).collect())
}
ActionWithServer::Update { mappings } => app::EwwCommand::UpdateVars(mappings.into_iter().collect()),
ActionWithServer::OpenWindow {
window_name,
pos,

View file

@ -10,9 +10,9 @@ use crate::{
};
use anyhow::*;
use app::EwwCommand;
use itertools::Itertools;
use dashmap::DashMap;
use glib;
use scheduled_executor;
use std::io::BufRead;
use self::script_var_process::ScriptVarProcess;

View file

@ -1,6 +1,5 @@
use crate::{app, config, eww_state::*, opts, script_var_handler, try_logging_errors, util};
use anyhow::*;
use log;
use std::{
collections::HashMap,
io::Write,
@ -25,8 +24,7 @@ pub fn initialize_server(should_detach: bool, action: opts::ActionWithServer) ->
let config_dir = config_file_path
.parent()
.context("config file did not have a parent?!")?
.to_owned()
.to_path_buf();
.to_owned();
let scss_file_path = config_dir.join("eww.scss");
log::info!("reading configuration from {:?}", &config_file_path);
@ -39,7 +37,7 @@ pub fn initialize_server(should_detach: bool, action: opts::ActionWithServer) ->
let script_var_handler = script_var_handler::ScriptVarHandler::new(evt_send.clone())?;
let mut app = app::App {
eww_state: EwwState::from_default_vars(eww_config.generate_initial_state()?.clone()),
eww_state: EwwState::from_default_vars(eww_config.generate_initial_state()?),
eww_config,
windows: HashMap::new(),
css_provider: gtk::CssProvider::new(),
@ -68,7 +66,7 @@ pub fn initialize_server(should_detach: bool, action: opts::ActionWithServer) ->
}
run_server_thread(evt_send.clone())?;
let _hotwatch = run_filewatch_thread(&config_file_path, &scss_file_path, evt_send.clone())?;
let _hotwatch = run_filewatch_thread(&config_file_path, &scss_file_path, evt_send)?;
evt_recv.attach(None, move |msg| {
app.handle_command(msg);

View file

@ -1,6 +1,5 @@
use anyhow::*;
use extend::ext;
use grass;
use itertools::Itertools;
use std::path::Path;

View file

@ -86,8 +86,7 @@ impl AttrValue {
curly_count = 2;
varref.push(c);
}
} else {
if c == '{' {
} else if c == '{' {
curly_count += 1;
if curly_count == 2 {
if !cur_word.is_empty() {
@ -103,11 +102,10 @@ impl AttrValue {
cur_word.push(c);
}
}
}
if let Some(unfinished_varref) = cur_varref.take() {
elements.push(AttrValueElement::primitive(unfinished_varref));
} else if !cur_word.is_empty() {
elements.push(AttrValueElement::primitive(cur_word.to_owned()));
elements.push(AttrValueElement::primitive(cur_word));
}
AttrValue(elements)
}

View file

@ -1,5 +1,4 @@
use anyhow::*;
use derive_more;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::{convert::TryFrom, fmt, iter::FromIterator};
@ -63,7 +62,7 @@ impl From<&str> for PrimitiveValue {
impl PrimitiveValue {
pub fn from_string(s: String) -> Self {
PrimitiveValue(s.to_string())
PrimitiveValue(s)
}
pub fn into_inner(self) -> String {

View file

@ -146,10 +146,12 @@ fn build_builtin_gtk_widget(
}
}
gtk_widget.dynamic_cast_ref().map(|w| resolve_range_attrs(&mut bargs, &w));
gtk_widget
.dynamic_cast_ref()
.map(|w| resolve_orientable_attrs(&mut bargs, &w));
if let Some(w) = gtk_widget.dynamic_cast_ref() {
resolve_range_attrs(&mut bargs, &w)
}
if let Some(w) = gtk_widget.dynamic_cast_ref() {
resolve_orientable_attrs(&mut bargs, &w)
};
resolve_widget_attrs(&mut bargs, &gtk_widget);
if !bargs.unhandled_attrs.is_empty() {

View file

@ -1,7 +1,6 @@
use super::{run_command, BuilderArgs};
use crate::{config, eww_state, resolve_block, value::AttrValue};
use anyhow::*;
use gdk_pixbuf;
use gtk::{prelude::*, ImageExt};
use std::{cell::RefCell, rc::Rc};