Skip to content

Commit

Permalink
fix: maintain compatibility with MSRV 1.62
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Oct 3, 2024
1 parent c621152 commit 237b72f
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,22 +699,23 @@ impl<'a, T: fmt::Display> fmt::Display for OxfordJoinFmt<'a, T> {
use core::cmp::Ordering;

// Split off the last part, or quit because the set is empty.
let Some((last, rest)) = self.inner.split_last() else { return Ok(()); };

// If last is all we have, it's all we print!
match rest.len().cmp(&1) {
// Last is all there is.
Ordering::Less => write!(f, "{last}"),

// Just one thing.
Ordering::Equal => write!(f, "{} {} {last}", rest[0], self.glue),

// Many things.
Ordering::Greater => {
for v in rest { write!(f, "{v}, ")?; }
write!(f, "{} {last}", self.glue)
},
if let Some((last, rest)) = self.inner.split_last() {
// If last is all we have, it's all we print!
match rest.len().cmp(&1) {
// Last is all there is.
Ordering::Less => write!(f, "{last}"),

// Just one thing.
Ordering::Equal => write!(f, "{} {} {last}", rest[0], self.glue),

// Many things.
Ordering::Greater => {
for v in rest { write!(f, "{v}, ")?; }
write!(f, "{} {last}", self.glue)
},
}
}
else { Ok(()) }
}
}

Expand Down

0 comments on commit 237b72f

Please sign in to comment.