Skip to content

Commit

Permalink
fix(rust): Fix type inference failure caused by double transpose (#17663
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ByteNybbler committed Jul 17, 2024
1 parent 91f4927 commit a970d16
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions crates/polars-plan/src/plans/ir/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit a970d16

Please sign in to comment.