From a970d161f7516014b4bb90b7c07e52c259ad7c9a Mon Sep 17 00:00:00 2001 From: "Paul C." Date: Wed, 17 Jul 2024 07:32:57 -0500 Subject: [PATCH] fix(rust): Fix type inference failure caused by double transpose (#17663) --- crates/polars-plan/src/plans/ir/dot.rs | 31 +++++++++----------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/crates/polars-plan/src/plans/ir/dot.rs b/crates/polars-plan/src/plans/ir/dot.rs index 43d7b158a013..45bdd0bb281c 100644 --- a/crates/polars-plan/src/plans/ir/dot.rs +++ b/crates/polars-plan/src/plans/ir/dot.rs @@ -397,30 +397,19 @@ impl<'a, 'b> fmt::Write for EscapeLabel<'a, 'b> { // This escapes quotes and new lines // @NOTE: I am aware this does not work for \" and such. I am ignoring that fact as we // are not really using such strings. - let f = char_indices - .find_map(|(i, c)| { - (|| match c { - '"' => { - self.0.write_str(&s[..i])?; - self.0.write_str(r#"\""#)?; - Ok(Some(i + 1)) - }, - '\n' => { - self.0.write_str(&s[..i])?; - self.0.write_str(r#"\n"#)?; - Ok(Some(i + 1)) - }, - _ => Ok(None), - })() - .transpose() - }) - .transpose()?; - - let Some(at) = f else { + let f = char_indices.find_map(|(i, c)| match c { + '"' => Some((i, r#"\""#)), + '\n' => Some((i, r#"\n"#)), + _ => None, + }); + + let Some((at, to_write)) = f else { break; }; - s = &s[at..]; + self.0.write_str(&s[..at])?; + self.0.write_str(to_write)?; + s = &s[at + 1..]; } self.0.write_str(s)?;