Shut up clippy.
This commit is contained in:
@@ -22,7 +22,7 @@ impl<'de> DynamicDeserializer<'de> {
|
||||
/// The reference is necessary because the deserialized type may hold references
|
||||
/// (especially `&str`) to the source [`Dynamic`][crate::Dynamic].
|
||||
#[must_use]
|
||||
pub fn from_dynamic(value: &'de Dynamic) -> Self {
|
||||
pub const fn from_dynamic(value: &'de Dynamic) -> Self {
|
||||
Self { value }
|
||||
}
|
||||
/// Shortcut for a type conversion error.
|
||||
@@ -449,21 +449,22 @@ impl<'de> Deserializer<'de> for &mut DynamicDeserializer<'de> {
|
||||
visitor.visit_enum(s.as_str().into_deserializer())
|
||||
} else {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
if let Some(map) = self.value.downcast_ref::<crate::Map>() {
|
||||
let mut iter = map.iter();
|
||||
let first = iter.next();
|
||||
let second = iter.next();
|
||||
if let (Some((key, value)), None) = (first, second) {
|
||||
visitor.visit_enum(EnumDeserializer {
|
||||
tag: key,
|
||||
content: DynamicDeserializer::from_dynamic(value),
|
||||
})
|
||||
} else {
|
||||
self.type_error()
|
||||
}
|
||||
} else {
|
||||
self.type_error()
|
||||
}
|
||||
return self.value.downcast_ref::<crate::Map>().map_or_else(
|
||||
|| self.type_error(),
|
||||
|map| {
|
||||
let mut iter = map.iter();
|
||||
let first = iter.next();
|
||||
let second = iter.next();
|
||||
if let (Some((key, value)), None) = (first, second) {
|
||||
visitor.visit_enum(EnumDeserializer {
|
||||
tag: key,
|
||||
content: DynamicDeserializer::from_dynamic(value),
|
||||
})
|
||||
} else {
|
||||
self.type_error()
|
||||
}
|
||||
},
|
||||
);
|
||||
#[cfg(feature = "no_object")]
|
||||
return self.type_error();
|
||||
}
|
||||
@@ -488,7 +489,7 @@ struct IterateDynamicArray<'a, ITER: Iterator<Item = &'a Dynamic>> {
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
impl<'a, ITER: Iterator<Item = &'a Dynamic>> IterateDynamicArray<'a, ITER> {
|
||||
#[must_use]
|
||||
pub fn new(iter: ITER) -> Self {
|
||||
pub const fn new(iter: ITER) -> Self {
|
||||
Self { iter }
|
||||
}
|
||||
}
|
||||
@@ -525,7 +526,7 @@ struct IterateMap<'a, K: Iterator<Item = &'a str>, V: Iterator<Item = &'a Dynami
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
impl<'a, K: Iterator<Item = &'a str>, V: Iterator<Item = &'a Dynamic>> IterateMap<'a, K, V> {
|
||||
#[must_use]
|
||||
pub fn new(keys: K, values: V) -> Self {
|
||||
pub const fn new(keys: K, values: V) -> Self {
|
||||
Self { keys, values }
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ impl PartialOrd for FnMetadata<'_> {
|
||||
|
||||
impl Ord for FnMetadata<'_> {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match self.name.cmp(&other.name) {
|
||||
match self.name.cmp(other.name) {
|
||||
Ordering::Equal => self.num_params.cmp(&other.num_params),
|
||||
cmp => cmp,
|
||||
}
|
||||
@@ -79,8 +79,8 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> {
|
||||
base_hash,
|
||||
full_hash,
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
namespace: info.metadata.namespace.into(),
|
||||
access: info.metadata.access.into(),
|
||||
namespace: info.metadata.namespace,
|
||||
access: info.metadata.access,
|
||||
name: &info.metadata.name,
|
||||
typ,
|
||||
num_params: info.metadata.params,
|
||||
@@ -150,7 +150,7 @@ impl<'a> From<&'a crate::Module> for ModuleMetadata<'a> {
|
||||
functions.sort();
|
||||
|
||||
Self {
|
||||
doc: module.doc().into(),
|
||||
doc: module.doc(),
|
||||
modules: module
|
||||
.iter_sub_modules()
|
||||
.map(|(name, m)| (name, m.as_ref().into()))
|
||||
@@ -206,7 +206,7 @@ pub fn gen_metadata_to_json(
|
||||
|
||||
#[cfg(feature = "metadata")]
|
||||
if let Some(ast) = _ast {
|
||||
global.doc = ast.doc().into();
|
||||
global.doc = ast.doc();
|
||||
}
|
||||
|
||||
serde_json::to_string_pretty(&global)
|
||||
|
@@ -20,7 +20,7 @@ struct DynamicSerializer {
|
||||
impl DynamicSerializer {
|
||||
/// Create a [`DynamicSerializer`] from a [`Dynamic`][crate::Dynamic] value.
|
||||
#[must_use]
|
||||
pub fn new(_value: Dynamic) -> Self {
|
||||
pub const fn new(_value: Dynamic) -> Self {
|
||||
Self {
|
||||
_key: Dynamic::UNIT,
|
||||
_value,
|
||||
|
@@ -14,7 +14,7 @@ pub struct StringSliceDeserializer<'a> {
|
||||
impl<'a> StringSliceDeserializer<'a> {
|
||||
/// Create an `ImmutableStringDeserializer` from an `&str` reference.
|
||||
#[must_use]
|
||||
pub fn from_str(value: &'a str) -> Self {
|
||||
pub const fn from_str(value: &'a str) -> Self {
|
||||
Self { value }
|
||||
}
|
||||
/// Shortcut for a type conversion error.
|
||||
|
Reference in New Issue
Block a user