Add #[must_use]

This commit is contained in:
Stephen Chung
2021-06-12 22:47:43 +08:00
parent 68ea8c27fd
commit 8ca24059b1
28 changed files with 489 additions and 55 deletions

View File

@@ -28,14 +28,17 @@ 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 {
Self { value }
}
/// Shortcut for a type conversion error.
#[must_use]
fn type_error<T>(&self) -> Result<T, Box<EvalAltResult>> {
self.type_error_str(type_name::<T>())
}
/// Shortcut for a type conversion error.
#[must_use]
fn type_error_str<T>(&self, error: &str) -> Result<T, Box<EvalAltResult>> {
EvalAltResult::ErrorMismatchOutputType(
error.into(),
@@ -44,6 +47,7 @@ impl<'de> DynamicDeserializer<'de> {
)
.into()
}
#[must_use]
fn deserialize_int<V: Visitor<'de>>(
&mut self,
v: crate::INT,
@@ -107,6 +111,7 @@ impl<'de> DynamicDeserializer<'de> {
/// # Ok(())
/// # }
/// ```
#[must_use]
pub fn from_dynamic<'de, T: Deserialize<'de>>(
value: &'de Dynamic,
) -> Result<T, Box<EvalAltResult>> {
@@ -494,6 +499,7 @@ struct IterateArray<'a, ITER: Iterator<Item = &'a Dynamic>> {
#[cfg(not(feature = "no_index"))]
impl<'a, ITER: Iterator<Item = &'a Dynamic>> IterateArray<'a, ITER> {
#[must_use]
pub fn new(iter: ITER) -> Self {
Self { iter }
}
@@ -534,6 +540,7 @@ where
KEYS: Iterator<Item = &'a str>,
VALUES: Iterator<Item = &'a Dynamic>,
{
#[must_use]
pub fn new(keys: KEYS, values: VALUES) -> Self {
Self { keys, values }
}