fix(clippy): silenced but i owe it my life

This commit is contained in:
Nova
2022-08-22 10:21:34 -04:00
parent a8bbfbafdf
commit 4335e2b216
7 changed files with 11 additions and 12 deletions

View File

@@ -3,11 +3,11 @@ use std::path::PathBuf;
pub type ResourceID = Box<dyn ResourceIDTrait + Send + Sync>; pub type ResourceID = Box<dyn ResourceIDTrait + Send + Sync>;
pub trait ResourceIDTrait { pub trait ResourceIDTrait {
fn get_file(&self, prefixes: &Vec<PathBuf>) -> Option<PathBuf>; fn get_file(&self, prefixes: &[PathBuf]) -> Option<PathBuf>;
} }
impl ResourceIDTrait for PathBuf { impl ResourceIDTrait for PathBuf {
fn get_file(&self, _prefixes: &Vec<PathBuf>) -> Option<PathBuf> { fn get_file(&self, _prefixes: &[PathBuf]) -> Option<PathBuf> {
if self.is_absolute() && self.as_path().exists() { if self.is_absolute() && self.as_path().exists() {
Some(self.clone()) Some(self.clone())
} else { } else {
@@ -22,7 +22,7 @@ pub struct NamespacedResourceID {
} }
impl ResourceIDTrait for NamespacedResourceID { impl ResourceIDTrait for NamespacedResourceID {
fn get_file(&self, prefixes: &Vec<PathBuf>) -> Option<PathBuf> { fn get_file(&self, prefixes: &[PathBuf]) -> Option<PathBuf> {
for prefix in prefixes { for prefix in prefixes {
let mut path = prefix.clone(); let mut path = prefix.clone();
path.push(self.namespace.clone()); path.push(self.namespace.clone());

View File

@@ -160,8 +160,7 @@ impl Node {
} }
} }
pub fn send_remote_signal(&self, method: &str, data: &[u8]) -> Result<()> { pub fn send_remote_signal(&self, method: &str, data: &[u8]) -> Result<()> {
let _ = self self.aliases
.aliases
.get_valid_contents() .get_valid_contents()
.iter() .iter()
.filter(|alias| alias.remote_signals.iter().any(|e| e == &method)) .filter(|alias| alias.remote_signals.iter().any(|e| e == &method))

View File

@@ -158,7 +158,7 @@ pub struct PulseReceiver {
pub mask: Mutex<Mask>, pub mask: Mutex<Mask>,
field: Weak<Field>, field: Weak<Field>,
} }
impl<'a> PulseReceiver { impl PulseReceiver {
pub fn add_to(node: &Arc<Node>, field: Arc<Field>) -> Result<()> { pub fn add_to(node: &Arc<Node>, field: Arc<Field>) -> Result<()> {
ensure!( ensure!(
node.spatial.get().is_some(), node.spatial.get().is_some(),

View File

@@ -62,7 +62,7 @@ impl Model {
model_arc model_arc
.resource_id .resource_id
.get_file(&node.get_client().base_resource_prefixes.lock().clone()) .get_file(&node.get_client().base_resource_prefixes.lock().clone())
.ok_or(anyhow!("Resource not found"))?, .ok_or_else(|| anyhow!("Resource not found"))?,
); );
let _ = node.model.set(model_arc.clone()); let _ = node.model.set(model_arc.clone());
Ok(model_arc) Ok(model_arc)
@@ -75,7 +75,7 @@ impl Model {
self.pending_model_path self.pending_model_path
.get() .get()
.and_then(|path| SKModel::from_file(sk, path.as_path(), None)) .and_then(|path| SKModel::from_file(sk, path.as_path(), None))
.map(|model| SendWrapper::new(model)) .map(SendWrapper::new)
.ok_or(Error) .ok_or(Error)
}) })
.ok(); .ok();

View File

@@ -56,7 +56,7 @@ impl Root {
*calling_client.base_resource_prefixes.lock() = flex_vec *calling_client.base_resource_prefixes.lock() = flex_vec
.iter() .iter()
.filter_map(|prefix| prefix.get_str().ok()) .filter_map(|prefix| prefix.get_str().ok())
.map(|prefix| PathBuf::from(prefix)) .map(PathBuf::from)
.filter(|prefix| prefix.is_absolute()) .filter(|prefix| prefix.is_absolute())
.collect(); .collect();
Ok(()) Ok(())

View File

@@ -29,7 +29,7 @@ impl CompositorHandler for WaylandState {
.borrow() .borrow()
.texture(&self.renderer) .texture(&self.renderer)
.cloned() .cloned()
.map(|renderer| SendWrapper::new(renderer)), .map(SendWrapper::new),
); );
} }
} }

View File

@@ -28,7 +28,7 @@ impl XdgShellHandler for WaylandState {
surface.send_configure(); surface.send_configure();
compositor::with_states(surface.wl_surface(), |data| { compositor::with_states(surface.wl_surface(), |data| {
data.data_map.insert_if_missing(|| CoreSurface::new()); data.data_map.insert_if_missing(CoreSurface::new);
}); });
} }
@@ -43,7 +43,7 @@ impl XdgShellHandler for WaylandState {
let _ = surface.send_configure(); let _ = surface.send_configure();
compositor::with_states(surface.wl_surface(), |data| { compositor::with_states(surface.wl_surface(), |data| {
data.data_map.insert_if_missing(|| CoreSurface::new()); data.data_map.insert_if_missing(CoreSurface::new);
}); });
} }