From c4901e857d3a64e7f46129fbe45a8bd00c9f3cb9 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 7 Aug 2024 11:47:07 +0200 Subject: [PATCH] Fmt. --- bindings/python/src/utils/serde_pyo3.rs | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/bindings/python/src/utils/serde_pyo3.rs b/bindings/python/src/utils/serde_pyo3.rs index b7a189bd7..471993614 100644 --- a/bindings/python/src/utils/serde_pyo3.rs +++ b/bindings/python/src/utils/serde_pyo3.rs @@ -33,7 +33,7 @@ where max_depth, max_elements, num_elements: vec![0; max_depth], - max_string + max_string, }; value.serialize(&mut serializer)?; Ok(serializer.output) @@ -51,7 +51,7 @@ where max_depth, max_elements: 100, num_elements: vec![0; max_depth], - max_string + max_string, }; value.serialize(&mut serializer)?; Ok(serializer.output) @@ -149,10 +149,10 @@ impl<'a> ser::Serializer for &'a mut Serializer { // contains a '"' character. fn serialize_str(self, v: &str) -> Result<()> { self.output += "\""; - if v.len() > self.max_string{ + if v.len() > self.max_string { self.output += &v[..self.max_string]; self.output += "..."; - }else{ + } else { self.output += v; } self.output += "\""; @@ -261,7 +261,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { // support sequences for which the length is known up front. fn serialize_seq(self, _len: Option) -> Result { self.output += "["; - self.level = std::cmp::min(self.max_depth- 1, self.level + 1); + self.level = std::cmp::min(self.max_depth - 1, self.level + 1); self.num_elements[self.level] = 0; Ok(self) } @@ -272,7 +272,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { // length without needing to look at the serialized data. fn serialize_tuple(self, _len: usize) -> Result { self.output += "("; - self.level = std::cmp::min(self.max_depth- 1, self.level + 1); + self.level = std::cmp::min(self.max_depth - 1, self.level + 1); self.num_elements[self.level] = 0; Ok(self) } @@ -298,7 +298,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { // variant.serialize(&mut *self)?; self.output += variant; self.output += "("; - self.level = std::cmp::min(self.max_depth- 1, self.level + 1); + self.level = std::cmp::min(self.max_depth - 1, self.level + 1); self.num_elements[self.level] = 0; Ok(self) } @@ -306,7 +306,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { // Maps are represented in JSON as `{ K: V, K: V, ... }`. fn serialize_map(self, _len: Option) -> Result { self.output += "{"; - self.level = std::cmp::min(self.max_depth- 1, self.level + 1); + self.level = std::cmp::min(self.max_depth - 1, self.level + 1); self.num_elements[self.level] = 0; Ok(self) } @@ -325,7 +325,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { self.output += name } self.output += "("; - self.level = std::cmp::min(self.max_depth- 1, self.level + 1); + self.level = std::cmp::min(self.max_depth - 1, self.level + 1); self.num_elements[self.level] = 0; Ok(self) } @@ -342,7 +342,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { // variant.serialize(&mut *self)?; self.output += variant; self.output += "("; - self.level = std::cmp::min(self.max_depth- 1, self.level + 1); + self.level = std::cmp::min(self.max_depth - 1, self.level + 1); self.num_elements[self.level] = 0; Ok(self) } @@ -368,13 +368,13 @@ impl<'a> ser::SerializeSeq for &'a mut Serializer { { self.num_elements[self.level] += 1; let num_elements = self.num_elements[self.level]; - if num_elements < self.max_elements{ + if num_elements < self.max_elements { if !self.output.ends_with('[') { self.output += ", "; } value.serialize(&mut **self) - }else{ - if num_elements == self.max_elements{ + } else { + if num_elements == self.max_elements { self.output += ", ..."; } Ok(()) @@ -401,13 +401,13 @@ impl<'a> ser::SerializeTuple for &'a mut Serializer { { self.num_elements[self.level] += 1; let num_elements = self.num_elements[self.level]; - if num_elements < self.max_elements{ + if num_elements < self.max_elements { if !self.output.ends_with('(') { self.output += ", "; } value.serialize(&mut **self) - }else{ - if num_elements == self.max_elements{ + } else { + if num_elements == self.max_elements { self.output += ", ..."; } Ok(()) @@ -433,13 +433,13 @@ impl<'a> ser::SerializeTupleStruct for &'a mut Serializer { { self.num_elements[self.level] += 1; let num_elements = self.num_elements[self.level]; - if num_elements < self.max_elements{ + if num_elements < self.max_elements { if !self.output.ends_with('(') { self.output += ", "; } value.serialize(&mut **self) - }else{ - if num_elements == self.max_elements{ + } else { + if num_elements == self.max_elements { self.output += ", ..."; } Ok(()) @@ -473,13 +473,13 @@ impl<'a> ser::SerializeTupleVariant for &'a mut Serializer { { self.num_elements[self.level] += 1; let num_elements = self.num_elements[self.level]; - if num_elements < self.max_elements{ + if num_elements < self.max_elements { if !self.output.ends_with('(') { self.output += ", "; } value.serialize(&mut **self) - }else{ - if num_elements == self.max_elements{ + } else { + if num_elements == self.max_elements { self.output += ", ..."; } Ok(()) @@ -520,13 +520,13 @@ impl<'a> ser::SerializeMap for &'a mut Serializer { { self.num_elements[self.level] += 1; let num_elements = self.num_elements[self.level]; - if num_elements < self.max_elements{ + if num_elements < self.max_elements { if !self.output.ends_with('{') { self.output += ", "; } key.serialize(&mut **self) - }else{ - if num_elements == self.max_elements{ + } else { + if num_elements == self.max_elements { self.output += ", ..."; } Ok(()) @@ -541,10 +541,10 @@ impl<'a> ser::SerializeMap for &'a mut Serializer { T: ?Sized + Serialize, { let num_elements = self.num_elements[self.level]; - if num_elements < self.max_elements{ + if num_elements < self.max_elements { self.output += ":"; value.serialize(&mut **self) - }else{ + } else { Ok(()) } }