mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-25 17:12:16 -05:00
refactor(varcon): Resolve winnow deprecations
This commit is contained in:
parent
ca9612c045
commit
a1ad167632
4 changed files with 40 additions and 45 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -2121,9 +2121,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.4.6"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699"
|
||||
checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
|
@ -14,7 +14,7 @@ include.workspace = true
|
|||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
winnow = "0.4.6"
|
||||
winnow = "0.4.9"
|
||||
unicode-xid = "0.2.4"
|
||||
once_cell = "1.17.2"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -16,7 +16,7 @@ parser = ["winnow"]
|
|||
flags = ["enumflags2"]
|
||||
|
||||
[dependencies]
|
||||
winnow = { version = "0.4.6", optional = true }
|
||||
winnow = { version = "0.4.9", optional = true }
|
||||
enumflags2 = { version = "0.7", optional = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
|
|
@ -63,25 +63,25 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
|
|||
impl Cluster {
|
||||
pub fn parse(input: &str) -> IResult<&str, Self> {
|
||||
let header = (
|
||||
winnow::bytes::tag("#"),
|
||||
winnow::character::space0,
|
||||
winnow::character::not_line_ending,
|
||||
winnow::character::line_ending,
|
||||
"#",
|
||||
winnow::ascii::space0,
|
||||
winnow::ascii::not_line_ending,
|
||||
winnow::ascii::line_ending,
|
||||
);
|
||||
let note = winnow::sequence::preceded(
|
||||
(winnow::bytes::tag("##"), winnow::character::space0),
|
||||
winnow::sequence::terminated(
|
||||
winnow::character::not_line_ending,
|
||||
winnow::character::line_ending,
|
||||
let note = winnow::combinator::preceded(
|
||||
("##", winnow::ascii::space0),
|
||||
winnow::combinator::terminated(
|
||||
winnow::ascii::not_line_ending,
|
||||
winnow::ascii::line_ending,
|
||||
),
|
||||
);
|
||||
let mut cluster = (
|
||||
winnow::combinator::opt(header),
|
||||
winnow::multi::many1(winnow::sequence::terminated(
|
||||
Entry::parse,
|
||||
winnow::character::line_ending,
|
||||
)),
|
||||
winnow::multi::many0(note),
|
||||
winnow::combinator::repeat(
|
||||
1..,
|
||||
winnow::combinator::terminated(Entry::parse, winnow::ascii::line_ending),
|
||||
),
|
||||
winnow::combinator::repeat(0.., note),
|
||||
);
|
||||
let (input, (header, entries, notes)): (_, (_, _, Vec<_>)) = cluster.parse_next(input)?;
|
||||
|
||||
|
@ -145,19 +145,19 @@ A B C: coloration's / B. Cv: colouration's
|
|||
|
||||
impl Entry {
|
||||
pub fn parse(input: &str) -> IResult<&str, Self> {
|
||||
let var_sep = (winnow::character::space0, '/', winnow::character::space0);
|
||||
let var_sep = (winnow::ascii::space0, '/', winnow::ascii::space0);
|
||||
let (input, variants) =
|
||||
winnow::multi::separated1(Variant::parse, var_sep).parse_next(input)?;
|
||||
winnow::combinator::separated1(Variant::parse, var_sep).parse_next(input)?;
|
||||
|
||||
let desc_sep = (winnow::character::space0, '|');
|
||||
let desc_sep = (winnow::ascii::space0, '|');
|
||||
let (input, description) =
|
||||
winnow::combinator::opt((desc_sep, Self::parse_description)).parse_next(input)?;
|
||||
|
||||
let comment_sep = (winnow::character::space0, '#');
|
||||
let comment_sep = (winnow::ascii::space0, '#');
|
||||
let (input, comment) = winnow::combinator::opt((
|
||||
comment_sep,
|
||||
winnow::character::space1,
|
||||
winnow::character::not_line_ending,
|
||||
winnow::ascii::space1,
|
||||
winnow::ascii::not_line_ending,
|
||||
))
|
||||
.parse_next(input)?;
|
||||
|
||||
|
@ -179,12 +179,12 @@ impl Entry {
|
|||
|
||||
fn parse_description(input: &str) -> IResult<&str, Self> {
|
||||
let (input, (pos, archaic, note, description)) = (
|
||||
winnow::combinator::opt((winnow::character::space1, Pos::parse)),
|
||||
winnow::combinator::opt((winnow::character::space1, "(-)")),
|
||||
winnow::combinator::opt((winnow::character::space1, "--")),
|
||||
winnow::combinator::opt((winnow::ascii::space1, Pos::parse)),
|
||||
winnow::combinator::opt((winnow::ascii::space1, "(-)")),
|
||||
winnow::combinator::opt((winnow::ascii::space1, "--")),
|
||||
winnow::combinator::opt((
|
||||
winnow::character::space1,
|
||||
winnow::bytes::take_till0(|c| c == '\n' || c == '\r' || c == '#'),
|
||||
winnow::ascii::space1,
|
||||
winnow::token::take_till0(('\n', '\r', '#')),
|
||||
)),
|
||||
)
|
||||
.parse_next(input)?;
|
||||
|
@ -298,17 +298,17 @@ mod test_entry {
|
|||
|
||||
impl Variant {
|
||||
pub fn parse(input: &str) -> IResult<&str, Self> {
|
||||
let types = winnow::multi::separated1(Type::parse, winnow::character::space1);
|
||||
let sep = (winnow::bytes::tag(":"), winnow::character::space0);
|
||||
let types = winnow::combinator::separated1(Type::parse, winnow::ascii::space1);
|
||||
let sep = (":", winnow::ascii::space0);
|
||||
let (input, (types, word)) =
|
||||
winnow::sequence::separated_pair(types, sep, word).parse_next(input)?;
|
||||
winnow::combinator::separated_pair(types, sep, word).parse_next(input)?;
|
||||
let v = Self { types, word };
|
||||
Ok((input, v))
|
||||
}
|
||||
}
|
||||
|
||||
fn word(input: &str) -> IResult<&str, String> {
|
||||
winnow::bytes::take_till1(|item: char| item.is_ascii_whitespace())
|
||||
winnow::token::take_till1(|item: char| item.is_ascii_whitespace())
|
||||
.map(|s: &str| s.to_owned().replace('_', " "))
|
||||
.parse_next(input)
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ impl Type {
|
|||
pub fn parse(input: &str) -> IResult<&str, Type> {
|
||||
let (input, category) = Category::parse(input)?;
|
||||
let (input, tag) = winnow::combinator::opt(Tag::parse).parse_next(input)?;
|
||||
let (input, num) = winnow::combinator::opt(winnow::character::digit1).parse_next(input)?;
|
||||
let (input, num) = winnow::combinator::opt(winnow::ascii::digit1).parse_next(input)?;
|
||||
let num = num.map(|s| s.parse().expect("parser ensured its a number"));
|
||||
let t = Type { category, tag, num };
|
||||
Ok((input, t))
|
||||
|
@ -439,7 +439,7 @@ mod test_type {
|
|||
|
||||
impl Category {
|
||||
pub fn parse(input: &str) -> IResult<&str, Category> {
|
||||
let symbols = winnow::bytes::one_of("ABZCD_");
|
||||
let symbols = winnow::token::one_of(['A', 'B', 'Z', 'C', 'D', '_']);
|
||||
symbols
|
||||
.map(|c| match c {
|
||||
'A' => Category::American,
|
||||
|
@ -475,7 +475,7 @@ mod test_category {
|
|||
|
||||
impl Tag {
|
||||
pub fn parse(input: &str) -> IResult<&str, Tag> {
|
||||
let symbols = winnow::bytes::one_of(".vV-x");
|
||||
let symbols = winnow::token::one_of(['.', 'v', 'V', '-', 'x']);
|
||||
symbols
|
||||
.map(|c| match c {
|
||||
'.' => Tag::Eq,
|
||||
|
@ -510,16 +510,11 @@ mod test_tag {
|
|||
|
||||
impl Pos {
|
||||
pub fn parse(input: &str) -> IResult<&str, Pos> {
|
||||
use winnow::bytes::tag;
|
||||
let noun = tag("<N>");
|
||||
let verb = tag("<V>");
|
||||
let adjective = tag("<Adj>");
|
||||
let adverb = tag("<Adv>");
|
||||
winnow::branch::alt((
|
||||
noun.value(Pos::Noun),
|
||||
verb.value(Pos::Verb),
|
||||
adjective.value(Pos::Adjective),
|
||||
adverb.value(Pos::Adverb),
|
||||
"<N>".value(Pos::Noun),
|
||||
"<V>".value(Pos::Verb),
|
||||
"<Adj>".value(Pos::Adjective),
|
||||
"<Adv>".value(Pos::Adverb),
|
||||
))
|
||||
.parse_next(input)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue