From a6cd4871a27c52080d92224e5d1d051e98718cb7 Mon Sep 17 00:00:00 2001 From: Christopher Sardegna Date: Thu, 28 Aug 2025 09:55:26 -0700 Subject: [PATCH] Rist 1.89 syntax --- src/deserializer/iter.rs | 37 ++++++++++++++++----------------- src/deserializer/typedstream.rs | 27 ++++++++++++------------ src/models/types.rs | 4 ++-- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/deserializer/iter.rs b/src/deserializer/iter.rs index 628aaa6..558b64d 100644 --- a/src/deserializer/iter.rs +++ b/src/deserializer/iter.rs @@ -142,26 +142,25 @@ impl<'a, 'b: 'a> Iterator for PropertyIterator<'a, 'b> { class: cls, data: _, }) = self.object_table.get(*idx) + && let Some(Archived::Class(cls)) = self.object_table.get(*cls) { - if let Some(Archived::Class(cls)) = self.object_table.get(*cls) { - let class_name = self - .type_table - .get(cls.name_index) - .and_then(|types| types.first()) - .and_then(|t| match t { - Type::String(name) => Some(*name), - _ => None, - }) - .unwrap_or("Unknown Class"); - // recurse into that object’s own data - let sub_iter = - PropertyIterator::new(self.object_table, self.type_table, *idx)?; - resolved.push(Property::Object { - class: cls, - name: class_name, - data: sub_iter, - }); - } + let class_name = self + .type_table + .get(cls.name_index) + .and_then(|types| types.first()) + .and_then(|t| match t { + Type::String(name) => Some(*name), + _ => None, + }) + .unwrap_or("Unknown Class"); + // recurse into that object’s own data + let sub_iter = + PropertyIterator::new(self.object_table, self.type_table, *idx)?; + resolved.push(Property::Object { + class: cls, + name: class_name, + data: sub_iter, + }); } } prim => resolved.push(Property::Primitive(prim)), diff --git a/src/deserializer/typedstream.rs b/src/deserializer/typedstream.rs index cc55ba7..c6c604a 100644 --- a/src/deserializer/typedstream.rs +++ b/src/deserializer/typedstream.rs @@ -232,10 +232,10 @@ impl<'a> TypedStreamDeserializer<'a> { // The class we just appended (*idx*) is the **parent** of the // class we appended in the previous iteration (*prev_new*) - if let Some(child_idx) = prev_new { - if let Archived::Class(ref mut child_cls) = self.object_table[child_idx] { - child_cls.parent_index = Some(idx); - } + if let Some(child_idx) = prev_new + && let Archived::Class(ref mut child_cls) = self.object_table[child_idx] + { + child_cls.parent_index = Some(idx); } // remember the first class we ever pushed @@ -264,10 +264,10 @@ impl<'a> TypedStreamDeserializer<'a> { // Patch the outer-most newly created class so that it points to the // already-existing parent (or to `None` if EMPTY terminated the list). - if let Some(outer_idx) = prev_new { - if let Archived::Class(ref mut outer_cls) = self.object_table[outer_idx] { - outer_cls.parent_index = final_parent; - } + if let Some(outer_idx) = prev_new + && let Archived::Class(ref mut outer_cls) = self.object_table[outer_idx] + { + outer_cls.parent_index = final_parent; } // Return the index of the bottom-most child we created first. @@ -294,15 +294,14 @@ impl<'a> TypedStreamDeserializer<'a> { // Read the next type, which should be an object if let Some(next_index) = self.read_type(false)? { // Recursively read the types for this object - if let Some(data) = self.read_types(next_index)? { - if let Some(Archived::Object { + if let Some(data) = self.read_types(next_index)? + && let Some(Archived::Object { class: _, data: data_vec, }) = self.object_table.get_mut(placeholder_index) - { - // Add the data to the object - data_vec.push(data); - } + { + // Add the data to the object + data_vec.push(data); } } } diff --git a/src/models/types.rs b/src/models/types.rs index fe8259c..622ecaf 100644 --- a/src/models/types.rs +++ b/src/models/types.rs @@ -93,7 +93,7 @@ impl<'a> Type<'a> { Self::String(str) } - pub(crate) fn get_array_length(types: &[u8]) -> Option> { + pub(crate) fn get_array_length(types: &'_ [u8]) -> Option>> { if types.first() == Some(&0x5b) { let len = types[1..] @@ -109,7 +109,7 @@ impl<'a> Type<'a> { None } - pub(crate) fn read_new_type(data: &[u8]) -> Result>> { + pub(crate) fn read_new_type(data: &'_ [u8]) -> Result>>> { // Get the type of the object let type_length = read_unsigned_int(data)?;