Clean up more clippy.

This commit is contained in:
Stephen Chung
2022-07-27 18:04:59 +08:00
parent 39dee556c4
commit 2f948a784c
47 changed files with 412 additions and 377 deletions

View File

@@ -42,7 +42,7 @@ impl ModuleResolversCollection {
/// ```
#[inline(always)]
#[must_use]
pub const fn new() -> Self {
pub fn new() -> Self {
Self(Vec::new())
}
/// Append a [module resolver][ModuleResolver] to the end.

View File

@@ -31,6 +31,7 @@ impl DummyModuleResolver {
/// engine.set_module_resolver(resolver);
/// ```
#[inline(always)]
#[must_use]
pub const fn new() -> Self {
Self
}

View File

@@ -244,10 +244,10 @@ impl FileModuleResolver {
let cache = locked_read(&self.cache);
if !cache.is_empty() {
cache.contains_key(path.as_ref())
} else {
if cache.is_empty() {
false
} else {
cache.contains_key(path.as_ref())
}
}
/// Empty the internal cache.
@@ -277,7 +277,7 @@ impl FileModuleResolver {
file_path = self
.base_path
.clone()
.or_else(|| source_path.map(|p| p.into()))
.or_else(|| source_path.map(Into::into))
.unwrap_or_default();
file_path.push(path);
} else {

View File

@@ -66,10 +66,10 @@ impl StaticModuleResolver {
#[inline(always)]
#[must_use]
pub fn contains_path(&self, path: &str) -> bool {
if !self.0.is_empty() {
self.0.contains_key(path)
} else {
if self.0.is_empty() {
false
} else {
self.0.contains_key(path)
}
}
/// Get an iterator of all the [modules][Module].
@@ -85,7 +85,7 @@ impl StaticModuleResolver {
/// Get an iterator of all the [module][Module] paths.
#[inline]
pub fn paths(&self) -> impl Iterator<Item = &str> {
self.0.keys().map(|s| s.as_str())
self.0.keys().map(SmartString::as_str)
}
/// Get an iterator of all the [modules][Module].
#[inline(always)]
@@ -100,6 +100,7 @@ impl StaticModuleResolver {
}
/// Is this [`StaticModuleResolver`] empty?
#[inline(always)]
#[must_use]
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}