Clean up clippy.

This commit is contained in:
Stephen Chung
2022-07-27 16:04:24 +08:00
parent 21f822020f
commit 39dee556c4
36 changed files with 271 additions and 369 deletions

View File

@@ -439,7 +439,7 @@ impl Hash for Dynamic {
mem::discriminant(&self.0).hash(state);
match self.0 {
Union::Unit(..) => ().hash(state),
Union::Unit(..) => (),
Union::Bool(ref b, ..) => b.hash(state),
Union::Str(ref s, ..) => s.hash(state),
Union::Char(ref c, ..) => c.hash(state),
@@ -1018,17 +1018,11 @@ impl Dynamic {
#[must_use]
pub fn is_read_only(&self) -> bool {
#[cfg(not(feature = "no_closure"))]
match self.0 {
// Shared values do not consider the current access mode
//Union::Shared(.., ReadOnly) => return true,
Union::Shared(ref cell, ..) => {
return match locked_read(cell).access_mode() {
ReadWrite => false,
ReadOnly => true,
}
}
_ => (),
if let Union::Shared(ref cell, ..) = self.0 {
return match locked_read(cell).access_mode() {
ReadWrite => false,
ReadOnly => true,
};
}
match self.access_mode() {
@@ -1368,14 +1362,11 @@ impl Dynamic {
#[must_use]
pub fn is_locked(&self) -> bool {
#[cfg(not(feature = "no_closure"))]
match self.0 {
Union::Shared(ref _cell, ..) => {
#[cfg(not(feature = "sync"))]
return _cell.try_borrow().is_err();
#[cfg(feature = "sync")]
return false;
}
_ => (),
if let Union::Shared(ref _cell, ..) = self.0 {
#[cfg(not(feature = "sync"))]
return _cell.try_borrow().is_err();
#[cfg(feature = "sync")]
return false;
}
false
@@ -1791,7 +1782,7 @@ impl Dynamic {
#[cfg(feature = "no_closure")]
let typ = v.type_name();
v.try_cast::<T>().ok_or_else(|| typ)
v.try_cast::<T>().ok_or(typ)
})
.collect(),
Union::Blob(..) if TypeId::of::<T>() == TypeId::of::<u8>() => Ok(self.cast::<Vec<T>>()),
@@ -1813,7 +1804,7 @@ impl Dynamic {
#[cfg(feature = "no_closure")]
let typ = v.type_name();
v.read_lock::<T>().ok_or_else(|| typ).map(|v| v.clone())
v.read_lock::<T>().ok_or(typ).map(|v| v.clone())
})
.collect()
}

View File

@@ -170,14 +170,14 @@ impl<'a> FromIterator<&'a str> for ImmutableString {
}
}
impl<'a> FromIterator<String> for ImmutableString {
impl FromIterator<String> for ImmutableString {
#[inline]
fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
Self(iter.into_iter().collect::<SmartString>().into())
}
}
impl<'a> FromIterator<SmartString> for ImmutableString {
impl FromIterator<SmartString> for ImmutableString {
#[inline]
fn from_iter<T: IntoIterator<Item = SmartString>>(iter: T) -> Self {
Self(iter.into_iter().collect::<SmartString>().into())

View File

@@ -112,7 +112,7 @@ impl Clone for Scope<'_> {
.collect(),
names: self.names.clone(),
aliases: self.aliases.clone(),
dummy: self.dummy.clone(),
dummy: self.dummy,
}
}
}
@@ -437,11 +437,9 @@ impl Scope<'_> {
/// ```
#[inline]
pub fn is_constant(&self, name: &str) -> Option<bool> {
self.get_index(name).and_then(|(.., access)| {
Some(match access {
AccessMode::ReadWrite => false,
AccessMode::ReadOnly => true,
})
self.get_index(name).map(|(.., access)| match access {
AccessMode::ReadWrite => false,
AccessMode::ReadOnly => true,
})
}
/// Update the value of the named entry in the [`Scope`] if it already exists and is not constant.