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