}
pos = peek_pos;
- description = format!("expected `'}}'`, found `{maybe:?}`");
+ description = format!("expected `'}}'`, found `{:?}`", maybe);
} else {
description = "expected `'}'` but string was terminated".to_owned();
// point at closing `"`
// fill character
if let Some(&(idx, c)) = self.cur.peek() {
- if let Some((_, '>' | '<' | '^')) = self.cur.clone().nth(1) {
- spec.fill = Some(c);
- spec.fill_span = Some(self.span(idx, idx + 1));
- self.cur.next();
+ match self.cur.clone().nth(1) {
+ Some((_, '>')) | Some((_, '<')) | Some((_, '^')) => {
+ spec.fill = Some(c);
+ spec.fill_span = Some(self.span(idx, idx + 1));
+ self.cur.next();
+ }
+ _ => {}
}
}
+
// Alignment
if self.consume('<') {
spec.align = AlignLeft;
);
}
- found.then_some(cur)
+ if found {
+ Some(cur)
+ } else {
+ None
+ }
}
fn suggest_format(&mut self) {
// If we only trimmed it off the input, `format!("\n")` would cause a mismatch as here we they actually match up.
// Alternatively, we could just count the trailing newlines and only trim one from the input if they don't match up.
let input_no_nl = input.trim_end_matches('\n');
- let Some(unescaped) = unescape_string(snippet) else {
- return InputStringKind::NotALiteral;
+ let unescaped = match unescape_string(snippet) {
+ Some(u) => u,
+ None => return InputStringKind::NotALiteral,
};
let unescaped_no_nl = unescaped.trim_end_matches('\n');
width_mappings.push(InnerWidthMapping::new(pos, width, 0));
}
- ('\\', Some((_, 'n' | 't' | 'r' | '0' | '\\' | '\'' | '\"'))) => {
+ ('\\', Some((_, 'n')))
+ | ('\\', Some((_, 't')))
+ | ('\\', Some((_, 'r')))
+ | ('\\', Some((_, '0')))
+ | ('\\', Some((_, '\\')))
+ | ('\\', Some((_, '\'')))
+ | ('\\', Some((_, '\"'))) => {
width_mappings.push(InnerWidthMapping::new(pos, 2, 1));
let _ = s.next();
}
.as_str()
.get(..digits_len)
.and_then(|digits| u32::from_str_radix(digits, 16).ok())
- .and_then(char::from_u32)
+ .and_then(std::char::from_u32)
.map_or(1, char::len_utf8);
// Skip the digits, for chars that encode to more than 1 utf-8 byte
let buf = string::String::from(string);
let ok = true;
- ok.then_some(buf)
+ if ok {
+ Some(buf)
+ } else {
+ None
+ }
}
// Assert a reasonable size for `Piece`