pub struct Loc {
pub file: Arc<PathBuf>,
pub lno: usize,
- pub section: Option<Arc<String>>,
+ pub section: Option<Arc<str>>,
}
#[derive(Debug,Clone)]
pub loc: Loc,
}
-pub type Parsed = HashMap<Arc<String>, Section>;
+pub type Parsed = HashMap<Arc<str>, Section>;
+#[derive(Debug)]
pub struct Section {
/// Location of first encounter
pub loc: Loc,
fn fmt(&self, f: &mut fmt::Formatter) {
write!(f, "{:?}:{}", &self.file, self.lno)?;
if let Some(s) = &self.section {
+ write!(f, " ")?;
let dbg = format!("{:?}", &s);
if let Some(mid) = (||{
let mid = dbg.strip_prefix(r#"""#)?;
let line = line.trim();
if line.is_empty() { continue }
- if regex_is_match!(r#"^ [;#] "#x, line) { continue }
+ if regex_is_match!(r#"^ [;\#] "#x, line) { continue }
let loc = Loc {
lno,
if let Some((_,new,)) =
regex_captures!(r#"^ \[ \s* (.+?) \s* \] $"#x, line)
{
- let new: Arc<String> = new.to_owned().into();
+ let new: Arc<str> = new.to_owned().into();
section.take(); // drops previous RefCell borrow of parsed
section = Some(new_section);
} else if let Some((_, key, val)) =
- regex_captures!(r#"^ ( [^\[] .*? ) \s* = \s* (.*) $"#, line)
+ regex_captures!(r#"^ ( [^\[] .*? ) \s* = \s* (.*) $"#x, line)
{
let val = Val { loc: loc.clone(), val: val.into() };