fix(varcon)!: Make cluster header required

This commit is contained in:
Ed Page 2024-08-23 13:35:30 -05:00
parent 19ed24a45f
commit 6e39b516fb
4 changed files with 7175 additions and 7185 deletions

View file

@ -1,6 +1,6 @@
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct Cluster { pub struct Cluster {
pub header: Option<&'static str>, pub header: &'static str,
pub entries: &'static [Entry], pub entries: &'static [Entry],
pub notes: &'static [&'static str], pub notes: &'static [&'static str],
} }
@ -8,7 +8,7 @@ pub struct Cluster {
impl Cluster { impl Cluster {
pub fn into_owned(self) -> crate::Cluster { pub fn into_owned(self) -> crate::Cluster {
crate::Cluster { crate::Cluster {
header: self.header.map(|s| s.to_owned()), header: self.header.to_owned(),
entries: self.entries.iter().map(|s| s.into_owned()).collect(), entries: self.entries.iter().map(|s| s.into_owned()).collect(),
notes: self.notes.iter().map(|s| (*s).to_owned()).collect(), notes: self.notes.iter().map(|s| (*s).to_owned()).collect(),
} }

View file

@ -12,7 +12,7 @@ pub use crate::parser::ClusterIter;
#[derive(Clone, PartialEq, Eq, Hash, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Cluster { pub struct Cluster {
pub header: Option<String>, pub header: String,
pub entries: Vec<Entry>, pub entries: Vec<Entry>,
pub notes: Vec<String>, pub notes: Vec<String>,
} }

View file

@ -54,9 +54,7 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
str![[r#" str![[r#"
[ [
Cluster { Cluster {
header: Some( header: "acknowledgment <verified> (level 35)",
"acknowledgment <verified> (level 35)",
),
entries: [ entries: [
Entry { Entry {
variants: [ variants: [
@ -231,9 +229,7 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
str![[r#" str![[r#"
[ [
Cluster { Cluster {
header: Some( header: "acknowledgment <verified> (level 35)",
"acknowledgment <verified> (level 35)",
),
entries: [ entries: [
Entry { Entry {
variants: [ variants: [
@ -383,9 +379,7 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
notes: [], notes: [],
}, },
Cluster { Cluster {
header: Some( header: "acknowledgment <verified> (level 35)",
"acknowledgment <verified> (level 35)",
),
entries: [ entries: [
Entry { Entry {
variants: [ variants: [
@ -559,7 +553,7 @@ impl Cluster {
terminated(winnow::ascii::till_line_ending, winnow::ascii::line_ending), terminated(winnow::ascii::till_line_ending, winnow::ascii::line_ending),
); );
let mut cluster = ( let mut cluster = (
opt(header), header,
winnow::combinator::repeat( winnow::combinator::repeat(
1.., 1..,
terminated(Entry::parse_, winnow::ascii::line_ending), terminated(Entry::parse_, winnow::ascii::line_ending),
@ -568,7 +562,7 @@ impl Cluster {
); );
let (header, entries, notes): (_, _, Vec<_>) = cluster.parse_next(input)?; let (header, entries, notes): (_, _, Vec<_>) = cluster.parse_next(input)?;
let header = header.map(|s| s.2.to_owned()); let header = header.2.to_owned();
let notes = notes.into_iter().map(|s| s.to_owned()).collect(); let notes = notes.into_iter().map(|s| s.to_owned()).collect();
let c = Self { let c = Self {
header, header,
@ -612,9 +606,7 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
actual.to_debug(), actual.to_debug(),
str![[r#" str![[r#"
Cluster { Cluster {
header: Some( header: "acknowledgment <verified> (level 35)",
"acknowledgment <verified> (level 35)",
),
entries: [ entries: [
Entry { Entry {
variants: [ variants: [
@ -793,9 +785,7 @@ A B C: coloration's / B. Cv: colouration's
actual.to_debug(), actual.to_debug(),
str![[r#" str![[r#"
Cluster { Cluster {
header: Some( header: "coloration <verified> (level 50)",
"coloration <verified> (level 50)",
),
entries: [ entries: [
Entry { Entry {
variants: [ variants: [

File diff suppressed because it is too large Load diff