Skip to content

Commit 62e409a

Browse files
authored
Merge pull request #7 from soulstompp/winnow-0.7
winnow-0.7 upgrade
2 parents f69d8b8 + 225ab21 commit 62e409a

39 files changed

+1073
-987
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## 0.2.0 - 2024-05-04
2+
* Changed parser signatures to meet winnow 0.7 standards
3+
* Removed dependency on galvanic-test which was accidentally left over from some initial design experiments.
4+
* Removed paste dependency which is no longer used.
5+
6+
## 0.1.0 - 2024-12-29
7+
8+
Initial release
9+
10+
* Best efforts to fully cover common specs

crates/winnow-datetime-assert/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "winnow_datetime_assert"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
description = "Testing/Benchmarking winnow-datetime parsers"
55
keywords = [ "iso8601", "date-time", "parser", "winnow" ]
66
categories = [ "parser-implementations", "date-and-time" ]
@@ -13,11 +13,9 @@ readme = "README.md"
1313
edition = "2021"
1414

1515
[dependencies]
16-
winnow_datetime = { path = "../winnow-datetime", version = "0.1.0", features = ["serde"] }
16+
winnow_datetime = { path = "../winnow-datetime", version = "0.2.0", features = ["serde"] }
1717
libtest-mimic = "0.8.1"
18-
galvanic-test = "0.2.0"
19-
winnow = "0.6.20"
20-
paste = "1.0.15"
18+
winnow = "0.7"
2119
serde = { version = "1.0", features = ["derive"] }
2220
serde_yaml = "0.9.34-deprecated"
2321

crates/winnow-datetime-assert/src/lib.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,41 @@ macro_rules! define_format_tests {
132132
(covered, uncovered)
133133
});
134134

135-
fn parse_input(input: &str) -> Result<$piece_type, String> {
136-
match terminated($parser, eof).parse_next(&mut input.as_bytes()) {
137-
Ok(p) => Ok(p),
138-
Err(e) => Err(format!("Failed to parse {}: {}", input, e)),
139-
}
135+
fn parse_input<'i, Input>(input: &mut Input) -> Result<$piece_type, String>
136+
where
137+
Input: StreamIsPartial
138+
+ Stream
139+
+ Compare<&'i str>
140+
+ AsBStr
141+
+ Clone
142+
+ std::fmt::Display,
143+
<Input as Stream>::Slice: AsBStr,
144+
<Input as Stream>::Token: AsChar + Clone,
145+
{
146+
let o = $parser::<Input, InputError<Input>>(input).map_err(|e| {
147+
format!(
148+
"Failed to parse datetime: {}: {}",
149+
String::from_utf8_lossy(input.as_bstr()),
150+
e.to_string()
151+
)
152+
})?;
153+
let _ = eof::<Input, InputError<Input>>(input).map_err(|e| {
154+
format!(
155+
"Remaining input parsing datetime: {}: {}",
156+
String::from_utf8_lossy(input.as_bstr()),
157+
e.to_string()
158+
)
159+
})?;
160+
161+
Ok(o)
140162
}
141163

142164
// Generate a trial for each assertion
143165
for assertion in covered {
144166
let name = format!("parses - {}", assertion.format);
145167
trials.push(Trial::test(name, move || {
146168
// Parse the input
147-
let result = parse_input(&assertion.input);
169+
let result = parse_input(&mut assertion.input.as_str());
148170

149171
// If covered, the result must match the expected value
150172
if result != Ok(assertion.expected) {
@@ -162,7 +184,7 @@ macro_rules! define_format_tests {
162184
let name = format!("rejects - {}", assertion.format);
163185
trials.push(Trial::test(name, move || {
164186
// Parse the input
165-
let result = parse_input(&assertion.input);
187+
let result = parse_input(&mut assertion.input.as_str());
166188

167189
// If not covered, the result must be an error
168190
if result.is_ok() {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 0.2.0 - 2015-05-04
2+
* Changed `Stream` helper type to `PartialInput` since this name conflicts with the winnow naming scheme and causes confusion.
3+
* Bumped winnow version to 0.7 and changed parser singatures to match standard winnow parsers
4+
5+
## 0.1.0 - 2014-12-29 - Initial Release

crates/winnow-datetime/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "winnow_datetime"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
description = "Parsing dates using winnow"
55
keywords = [ "iso8601", "date-time", "parser", "winnow" ]
66
categories = [ "parser-implementations", "date-and-time" ]
@@ -13,7 +13,7 @@ readme = "README.md"
1313
edition = "2021"
1414

1515
[dependencies]
16-
winnow = "0.6.20"
16+
winnow = "0.7"
1717
chrono = { version = "0.4", default-features = false, optional = true }
1818
time = { version = "0.3.37", default-features = false, optional = true }
1919
num-traits = { version = "0.2", optional = true }

crates/winnow-datetime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ pub use types::Time;
1818
use winnow::Partial;
1919

2020
/// Type for holding partial data for parsers
21-
pub type Stream<'i> = Partial<&'i [u8]>;
21+
pub type PartialInput<'i> = Partial<&'i [u8]>;

0 commit comments

Comments
 (0)