Clean up more clippy.
This commit is contained in:
@@ -739,7 +739,7 @@ impl Dynamic {
|
||||
/// A [`Dynamic`] containing the integer 1,000.
|
||||
pub const THOUSAND: Self = Self::from_int(1000);
|
||||
/// A [`Dynamic`] containing the integer 1,000,000.
|
||||
pub const MILLION: Self = Self::from_int(1000000);
|
||||
pub const MILLION: Self = Self::from_int(1_000_000);
|
||||
/// A [`Dynamic`] containing the integer -1.
|
||||
pub const NEGATIVE_ONE: Self = Self::from_int(-1);
|
||||
/// A [`Dynamic`] containing the integer -2.
|
||||
@@ -778,7 +778,7 @@ impl Dynamic {
|
||||
///
|
||||
/// Not available under `no_float`.
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
pub const FLOAT_MILLION: Self = Self::from_float(1000000.0);
|
||||
pub const FLOAT_MILLION: Self = Self::from_float(1_000_000.0);
|
||||
/// A [`Dynamic`] containing `-1.0`.
|
||||
///
|
||||
/// Not available under `no_float`.
|
||||
@@ -823,7 +823,7 @@ impl Dynamic {
|
||||
///
|
||||
/// Not available under `no_float`.
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
pub const FLOAT_MILLIONTH: Self = Self::from_float(0.000001);
|
||||
pub const FLOAT_MILLIONTH: Self = Self::from_float(0.000_001);
|
||||
/// A [`Dynamic`] containing π.
|
||||
///
|
||||
/// Not available under `no_float`.
|
||||
@@ -867,16 +867,19 @@ impl Dynamic {
|
||||
|
||||
/// Create a new [`Dynamic`] from a [`bool`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn from_bool(value: bool) -> Self {
|
||||
Self(Union::Bool(value, DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
/// Create a new [`Dynamic`] from an [`INT`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn from_int(value: INT) -> Self {
|
||||
Self(Union::Int(value, DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
/// Create a new [`Dynamic`] from a [`char`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn from_char(value: char) -> Self {
|
||||
Self(Union::Char(value, DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
@@ -885,6 +888,7 @@ impl Dynamic {
|
||||
/// Not available under `no_float`.
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn from_float(value: crate::FLOAT) -> Self {
|
||||
Self(Union::Float(
|
||||
crate::ast::FloatWrapper::new_const(value),
|
||||
@@ -897,24 +901,28 @@ impl Dynamic {
|
||||
/// Exported under the `decimal` feature only.
|
||||
#[cfg(feature = "decimal")]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn from_decimal(value: rust_decimal::Decimal) -> Self {
|
||||
Self(Union::Decimal(value.into(), DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
/// Create a [`Dynamic`] from an [`Array`][crate::Array].
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn from_array(array: crate::Array) -> Self {
|
||||
Self(Union::Array(array.into(), DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
/// Create a [`Dynamic`] from a [`Blob`][crate::Blob].
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn from_blob(blob: crate::Blob) -> Self {
|
||||
Self(Union::Blob(blob.into(), DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
/// Create a [`Dynamic`] from a [`Map`][crate::Map].
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn from_map(map: crate::Map) -> Self {
|
||||
Self(Union::Map(map.into(), DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
@@ -923,6 +931,7 @@ impl Dynamic {
|
||||
/// Not available under `no-std`.
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn from_timestamp(value: Instant) -> Self {
|
||||
Self(Union::TimeStamp(value.into(), DEFAULT_TAG_VALUE, ReadWrite))
|
||||
}
|
||||
@@ -993,6 +1002,7 @@ impl Dynamic {
|
||||
}
|
||||
/// Make this [`Dynamic`] read-only (i.e. a constant).
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn into_read_only(self) -> Self {
|
||||
let mut value = self;
|
||||
value.set_access_mode(AccessMode::ReadOnly);
|
||||
@@ -1388,13 +1398,13 @@ impl Dynamic {
|
||||
Union::Shared(ref cell, ..) => {
|
||||
let value = locked_read(cell);
|
||||
|
||||
if (*value).type_id() != TypeId::of::<T>()
|
||||
return if (*value).type_id() != TypeId::of::<T>()
|
||||
&& TypeId::of::<Dynamic>() != TypeId::of::<T>()
|
||||
{
|
||||
return None;
|
||||
None
|
||||
} else {
|
||||
return Some(DynamicReadLock(DynamicReadLockInner::Guard(value)));
|
||||
}
|
||||
Some(DynamicReadLock(DynamicReadLockInner::Guard(value)))
|
||||
};
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
@@ -1420,13 +1430,13 @@ impl Dynamic {
|
||||
Union::Shared(ref cell, ..) => {
|
||||
let guard = crate::func::locked_write(cell);
|
||||
|
||||
if (*guard).type_id() != TypeId::of::<T>()
|
||||
return if (*guard).type_id() != TypeId::of::<T>()
|
||||
&& TypeId::of::<Dynamic>() != TypeId::of::<T>()
|
||||
{
|
||||
return None;
|
||||
None
|
||||
} else {
|
||||
return Some(DynamicWriteLock(DynamicWriteLockInner::Guard(guard)));
|
||||
}
|
||||
Some(DynamicWriteLock(DynamicWriteLockInner::Guard(guard)))
|
||||
};
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@@ -24,15 +24,15 @@ pub struct FnPtr {
|
||||
|
||||
impl fmt::Debug for FnPtr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if !self.is_curried() {
|
||||
write!(f, "Fn({})", self.fn_name())
|
||||
} else {
|
||||
if self.is_curried() {
|
||||
self.curry
|
||||
.iter()
|
||||
.fold(f.debug_tuple("Fn").field(&self.name), |f, curry| {
|
||||
f.field(curry)
|
||||
})
|
||||
.finish()
|
||||
} else {
|
||||
write!(f, "Fn({})", self.fn_name())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ impl FnPtr {
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
_ast.as_ref(),
|
||||
];
|
||||
let lib = if lib.first().map(|m: &&Module| m.is_empty()).unwrap_or(true) {
|
||||
let lib = if lib.first().map_or(true, |m: &&Module| m.is_empty()) {
|
||||
&lib[0..0]
|
||||
} else {
|
||||
&lib
|
||||
|
@@ -159,7 +159,7 @@ impl FromIterator<char> for ImmutableString {
|
||||
impl<'a> FromIterator<&'a char> for ImmutableString {
|
||||
#[inline]
|
||||
fn from_iter<T: IntoIterator<Item = &'a char>>(iter: T) -> Self {
|
||||
Self(iter.into_iter().cloned().collect::<SmartString>().into())
|
||||
Self(iter.into_iter().copied().collect::<SmartString>().into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,6 +576,7 @@ impl PartialOrd<ImmutableString> for String {
|
||||
impl ImmutableString {
|
||||
/// Create a new [`ImmutableString`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self(SmartString::new_const().into())
|
||||
}
|
||||
@@ -583,6 +584,7 @@ impl ImmutableString {
|
||||
///
|
||||
/// If there are other references to the same string, a cloned copy is returned.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn into_owned(mut self) -> String {
|
||||
self.make_mut(); // Make sure it is unique reference
|
||||
shared_take(self.0).into() // Should succeed
|
||||
@@ -620,6 +622,7 @@ impl ImmutableString {
|
||||
/// assert!(!s2.ptr_eq(&s3));
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn ptr_eq(&self, other: &Self) -> bool {
|
||||
Shared::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
|
@@ -436,6 +436,7 @@ impl Scope<'_> {
|
||||
/// assert_eq!(my_scope.is_constant("y"), None);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn is_constant(&self, name: &str) -> Option<bool> {
|
||||
self.get_index(name).map(|(.., access)| match access {
|
||||
AccessMode::ReadWrite => false,
|
||||
|
Reference in New Issue
Block a user