#![deny(rust_2018_idioms, unsafe_code)]
#![allow(clippy::derive_partial_eq_without_eq)]
pub use self::{parser::parse_schema, reformat::reformat, source_file::SourceFile};
pub mod ast;
mod parser;
mod reformat;
mod renderer;
mod source_file;
pub fn string_literal(s: &str) -> impl std::fmt::Display + '_ {
struct StringLiteral<'a>(&'a str);
impl std::fmt::Display for StringLiteral<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("\"")?;
for c in self.0.char_indices() {
match c {
(_, '\t') => f.write_str("\\t")?,
(_, '\n') => f.write_str("\\n")?,
(_, '"') => f.write_str("\\\"")?,
(_, '\r') => f.write_str("\\r")?,
(_, '\\') => f.write_str("\\\\")?,
(_, c) if c.is_ascii_control() => {
let mut b = [0];
c.encode_utf8(&mut b);
f.write_fmt(format_args!("\\u{:04x}", b[0]))?;
}
(start, other) => f.write_str(&self.0[start..(start + other.len_utf8())])?,
}
}
f.write_str("\"")
}
}
StringLiteral(s)
}