fix: clippy

This commit is contained in:
Nova
2024-06-09 19:58:41 -04:00
parent 04535895e8
commit 99eb0ea547
31 changed files with 65 additions and 120 deletions

View File

@@ -142,11 +142,8 @@ impl Client {
let client = client.clone();
async move {
loop {
match messenger_rx.dispatch(&*scenegraph).await {
Err(e) => {
client.disconnect(Err(e.into()));
}
_ => (),
if let Err(e) = messenger_rx.dispatch(&*scenegraph).await {
client.disconnect(Err(e.into()));
}
}
}
@@ -160,11 +157,8 @@ impl Client {
let client = client.clone();
async move {
loop {
match messenger_tx.flush().await {
Err(e) => {
client.disconnect(Err(e.into()));
}
_ => (),
if let Err(e) = messenger_tx.flush().await {
client.disconnect(Err(e.into()));
}
}
}

View File

@@ -65,11 +65,11 @@ impl ClientStateParsed {
let file_string = std::fs::read_to_string(file).ok()?;
toml::from_str(&file_string).ok()
}
pub fn to_file(self, directory: &Path) {
pub fn to_file(&self, directory: &Path) {
let app_name = self
.launch_info
.as_ref()
.map(|l| l.cmdline.get(0).unwrap().split('/').last().unwrap())
.map(|l| l.cmdline.first().unwrap().split('/').last().unwrap())
.unwrap_or("unknown");
let state_file_path = directory
.join(format!("{app_name}-{}", nanoid::nanoid!()))

View File

@@ -3,9 +3,11 @@ use parking_lot::Mutex;
use std::any::Any;
use tokio::sync::mpsc::{self, unbounded_channel};
type Anything = Box<dyn Any + Send + Sync>;
static MAIN_DESTROY_QUEUE: Lazy<(
mpsc::UnboundedSender<Box<dyn Any + Send + Sync>>,
Mutex<mpsc::UnboundedReceiver<Box<dyn Any + Send + Sync>>>,
mpsc::UnboundedSender<Anything>,
Mutex<mpsc::UnboundedReceiver<Anything>>,
)> = Lazy::new(|| {
let (tx, rx) = unbounded_channel();
(tx, Mutex::new(rx))

View File

@@ -14,7 +14,7 @@ impl<T: Send + Sync + ?Sized> Registry<T> {
}
fn lock(&self) -> MappedMutexGuard<FxHashMap<usize, Weak<T>>> {
MutexGuard::map(self.0.lock(), |r| {
r.get_or_insert_with(|| FxHashMap::default())
r.get_or_insert_with(FxHashMap::default)
})
}
pub fn add(&self, t: T) -> Arc<T>
@@ -63,7 +63,7 @@ impl<T: Send + Sync + ?Sized> Registry<T> {
.collect()
}
pub fn set(&self, other: &Registry<T>) {
*self.lock() = other.lock().clone();
self.lock().clone_from(&other.lock());
}
pub fn take_valid_contents(&self) -> Vec<Arc<T>> {
self.0
@@ -119,7 +119,7 @@ impl<T: Send + Sync + ?Sized> OwnedRegistry<T> {
}
fn lock(&self) -> MappedMutexGuard<FxHashMap<usize, Arc<T>>> {
MutexGuard::map(self.0.lock(), |r| {
r.get_or_insert_with(|| FxHashMap::default())
r.get_or_insert_with(FxHashMap::default)
})
}
pub fn add(&self, t: T) -> Arc<T>

View File

@@ -1,13 +1,16 @@
use stardust_xr::values::ResourceID;
use std::{ffi::OsStr, path::PathBuf};
use std::{
ffi::OsStr,
path::{Path, PathBuf},
};
use super::client::Client;
lazy_static::lazy_static! {
static ref THEMES: Vec<PathBuf> = std::env::var("STARDUST_THEMES").map(|s| s.split(":").map(PathBuf::from).collect()).unwrap_or_default();
static ref THEMES: Vec<PathBuf> = std::env::var("STARDUST_THEMES").map(|s| s.split(':').map(PathBuf::from).collect()).unwrap_or_default();
}
fn has_extension(path: &PathBuf, extensions: &[&OsStr]) -> bool {
fn has_extension(path: &Path, extensions: &[&OsStr]) -> bool {
if let Some(path_extension) = path.extension() {
extensions.contains(&path_extension)
} else {

View File

@@ -47,7 +47,8 @@ impl Scenegraph {
}
}
pub struct MethodResponseSender(oneshot::Sender<Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError>>);
pub type MethodResponse = Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError>;
pub struct MethodResponseSender(oneshot::Sender<MethodResponse>);
impl MethodResponseSender {
pub fn send(self, t: Result<Message, ScenegraphError>) {
let _ = self.0.send(t.map(|m| (m.data, m.fds)));