//! Parsing does not happen at runtime: structures of `std::fmt::rt` are
//! generated instead.
-#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
- html_playground_url = "https://play.rust-lang.org/",
- test(attr(deny(warnings))))]
-
+#![doc(
+ html_root_url = "https://doc.rust-lang.org/nightly/",
+ html_playground_url = "https://play.rust-lang.org/",
+ test(attr(deny(warnings)))
+)]
#![feature(nll)]
#![feature(rustc_private)]
#![feature(unicode_internals)]
+#![feature(bool_to_option)]
-pub use Piece::*;
-pub use Position::*;
pub use Alignment::*;
-pub use Flag::*;
pub use Count::*;
+pub use Flag::*;
+pub use Piece::*;
+pub use Position::*;
+use std::iter;
use std::str;
use std::string;
-use std::iter;
use syntax_pos::{InnerSpan, Symbol};
None
}
}
- '\n' => {
- Some(String(self.string(pos)))
- }
+ '\n' => Some(String(self.string(pos))),
_ => Some(String(self.string(pos))),
}
} else {
/// Notifies of an error. The message doesn't actually need to be of type
/// String, but I think it does when this eventually uses conditions so it
/// might as well start using it now.
- fn err_with_note<S1: Into<string::String>, S2: Into<string::String>, S3: Into<string::String>>(
+ fn err_with_note<
+ S1: Into<string::String>,
+ S2: Into<string::String>,
+ S3: Into<string::String>,
+ >(
&mut self,
description: S1,
label: S2,
let description = format!("expected `'}}'`, found `{:?}`", maybe);
let label = "expected `}`".to_owned();
let (note, secondary_label) = if c == '}' {
- (Some("if you intended to print `{`, you can escape it using `{{`".to_owned()),
- self.last_opening_brace.map(|sp| {
- ("because of this opening brace".to_owned(), sp)
- }))
+ (
+ Some(
+ "if you intended to print `{`, you can escape it using `{{`".to_owned(),
+ ),
+ self.last_opening_brace
+ .map(|sp| ("because of this opening brace".to_owned(), sp)),
+ )
} else {
(None, None)
};
if c == '}' {
let label = format!("expected `{:?}`", c);
let (note, secondary_label) = if c == '}' {
- (Some("if you intended to print `{`, you can escape it using `{{`".to_owned()),
- self.last_opening_brace.map(|sp| {
- ("because of this opening brace".to_owned(), sp)
- }))
+ (
+ Some(
+ "if you intended to print `{`, you can escape it using `{{`".to_owned(),
+ ),
+ self.last_opening_brace
+ .map(|sp| ("because of this opening brace".to_owned(), sp)),
+ )
} else {
(None, None)
};
}
};
- Argument {
- position: pos,
- format,
- }
+ Argument { position: pos, format }
}
/// Parses a positional argument for a format. This could either be an
}
}
if !havewidth {
- let width_span_start = if let Some((pos, _)) = self.cur.peek() {
- *pos
- } else {
- 0
- };
+ let width_span_start = if let Some((pos, _)) = self.cur.peek() { *pos } else { 0 };
let (w, sp) = self.count(width_span_start);
spec.width = w;
spec.width_span = sp;
break;
}
}
- if found {
- Some(cur)
- } else {
- None
- }
+ found.then_some(cur)
}
}