mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 00:51:11 -05:00
refactor(varcon): Mutate, rather than initialize
This commit is contained in:
parent
62aab867ab
commit
c1644d8876
1 changed files with 14 additions and 14 deletions
|
@ -991,6 +991,15 @@ impl Entry {
|
||||||
|
|
||||||
fn parse_description(input: &mut &str) -> PResult<Self, ()> {
|
fn parse_description(input: &mut &str) -> PResult<Self, ()> {
|
||||||
trace("description", move |input: &mut &str| {
|
trace("description", move |input: &mut &str| {
|
||||||
|
let mut entry = Self {
|
||||||
|
variants: Vec::new(),
|
||||||
|
pos: None,
|
||||||
|
archaic: false,
|
||||||
|
note: false,
|
||||||
|
description: None,
|
||||||
|
comment: None,
|
||||||
|
};
|
||||||
|
|
||||||
let _ = opt((space1, "<abbr>")).parse_next(input)?;
|
let _ = opt((space1, "<abbr>")).parse_next(input)?;
|
||||||
let _ = opt((space1, "<pl>")).parse_next(input)?;
|
let _ = opt((space1, "<pl>")).parse_next(input)?;
|
||||||
let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>'))))
|
let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>'))))
|
||||||
|
@ -999,20 +1008,11 @@ impl Entry {
|
||||||
let note = opt((space1, NOTE_PREFIX)).parse_next(input)?;
|
let note = opt((space1, NOTE_PREFIX)).parse_next(input)?;
|
||||||
let description = opt((space1, description)).parse_next(input)?;
|
let description = opt((space1, description)).parse_next(input)?;
|
||||||
|
|
||||||
let variants = Vec::new();
|
entry.pos = pos.map(|(_, p)| p);
|
||||||
let pos = pos.map(|(_, p)| p);
|
entry.archaic = archaic.is_some();
|
||||||
let archaic = archaic.is_some();
|
entry.note = note.is_some();
|
||||||
let note = note.is_some();
|
entry.description = description.map(|(_, d)| d.to_owned());
|
||||||
let description = description.map(|(_, d)| d.to_owned());
|
Ok(entry)
|
||||||
let e = Self {
|
|
||||||
variants,
|
|
||||||
pos,
|
|
||||||
archaic,
|
|
||||||
note,
|
|
||||||
description,
|
|
||||||
comment: None,
|
|
||||||
};
|
|
||||||
Ok(e)
|
|
||||||
})
|
})
|
||||||
.parse_next(input)
|
.parse_next(input)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue