Skip to content

Commit

Permalink
refactor: fix new strict clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed Feb 1, 2024
1 parent d58d895 commit aaef3bf
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 29 deletions.
6 changes: 4 additions & 2 deletions src/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Bar {
Propagation::Proceed
});

Bar {
Self {
name,
monitor_name,
position,
Expand Down Expand Up @@ -131,7 +131,9 @@ impl Bar {
monitor,
);

let start_hidden = config.start_hidden.unwrap_or(config.autohide.is_some());
let start_hidden = config
.start_hidden
.unwrap_or_else(|| config.autohide.is_some());

if let Some(autohide) = config.autohide {
let hotspot_window = Window::new(WindowType::Toplevel);
Expand Down
8 changes: 4 additions & 4 deletions src/clients/compositor/hyprland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ impl Client {

impl WorkspaceClient for Client {
fn focus(&self, id: String) -> Result<()> {
let identifier = match id.parse::<i32>() {
Ok(inum) => WorkspaceIdentifierWithSpecial::Id(inum),
Err(_) => WorkspaceIdentifierWithSpecial::Name(&id),
};
let identifier = id.parse::<i32>().map_or_else(
|_| WorkspaceIdentifierWithSpecial::Name(&id),
WorkspaceIdentifierWithSpecial::Id,
);

Dispatch::call(DispatchType::Workspace(identifier))?;
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/clients/wayland/macros.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// It is necessary to store macros in a separate file due to a compilation error.
/// I believe this stems from the feature flags.
/// Related issue: <https://github.com/rust-lang/rust/issues/81066>
//! It is necessary to store macros in a separate file due to a compilation error.
//! I believe this stems from the feature flags.
//! Related issue: <https://github.com/rust-lang/rust/issues/81066>
// --- Data Control Device --- \\

Expand Down
2 changes: 1 addition & 1 deletion src/clients/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct BroadcastChannel<T>(broadcast::Sender<T>, Arc<Mutex<broadcast::Receiver<T

impl<T> From<(broadcast::Sender<T>, broadcast::Receiver<T>)> for BroadcastChannel<T> {
fn from(value: (broadcast::Sender<T>, broadcast::Receiver<T>)) -> Self {
BroadcastChannel(value.0, arc_mut!(value.1))
Self(value.0, arc_mut!(value.1))
}
}

Expand Down
16 changes: 6 additions & 10 deletions src/desktop_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,16 @@ fn find_desktop_file_by_filedata(app_id: &str, files: &[PathBuf]) -> Option<Path
.find(|(_, desktop_file)| {
desktop_file
.get("Name")
.map(|names| names.iter().any(|name| name.eq_ignore_ascii_case(app_id)))
.unwrap_or_default()
.is_some_and(|names| names.iter().any(|name| name.eq_ignore_ascii_case(app_id)))
})
// second pass - check name key for substring
.or_else(|| {
files.iter().find(|(_, desktop_file)| {
desktop_file
.get("Name")
.map(|names| {
names
.iter()
.any(|name| name.to_lowercase().contains(app_id))
})
.unwrap_or_default()
desktop_file.get("Name").is_some_and(|names| {
names
.iter()
.any(|name| name.to_lowercase().contains(app_id))
})
})
})
// third pass - check all keys for substring
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic_value/dynamic_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl DynamicBool {
let mut rx = crate::write_lock!(variable_manager).subscribe(variable_name);

while let Ok(value) = rx.recv().await {
let has_value = value.map(|s| is_truthy(&s)).unwrap_or_default();
let has_value = value.is_some_and(|s| is_truthy(&s));
send_async!(tx, has_value);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl Ironbar {
OutputEventType::New => {
match load_output_bars(&instance, &app, event.output) {
Ok(mut new_bars) => {
instance.bars.borrow_mut().append(&mut new_bars)
instance.bars.borrow_mut().append(&mut new_bars);
}
Err(err) => error!("{err:?}"),
}
Expand Down Expand Up @@ -326,7 +326,9 @@ fn load_output_bars(
let display = get_display();

let pos = output.logical_position.unwrap_or_default();
let monitor = display.monitor_at_point(pos.0, pos.1).unwrap();
let monitor = display
.monitor_at_point(pos.0, pos.1)
.expect("monitor to exist");

let show_default_bar =
config.start.is_some() || config.center.is_some() || config.end.is_some();
Expand Down
7 changes: 1 addition & 6 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ pub fn load_css(style_path: PathBuf) {
let mut watcher = recommended_watcher(move |res: Result<Event>| match res {
Ok(event) if matches!(event.kind, EventKind::Modify(ModifyKind::Data(_))) => {
debug!("{event:?}");
if event
.paths
.first()
.map(|p| p == &style_path2)
.unwrap_or_default()
{
if event.paths.first().is_some_and(|p| p == &style_path2) {
try_send!(tx, style_path2.clone());
}
}
Expand Down

0 comments on commit aaef3bf

Please sign in to comment.