push
This commit is contained in:
parent
9beaaeea67
commit
745fc4bfe4
54
src/law.rs
54
src/law.rs
@ -17,6 +17,16 @@ struct Heading {
|
|||||||
content: HeadingContent, // 1. Theil; 1. Subtheil; ...
|
content: HeadingContent, // 1. Theil; 1. Subtheil; ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Heading {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
if let Some(desc) = &self.desc {
|
||||||
|
f.write_str(&format!("{} ({desc})\n", self.name))
|
||||||
|
} else {
|
||||||
|
f.write_str(&format!("{}\n", self.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
enum HeadingContent {
|
enum HeadingContent {
|
||||||
Paragraph(Vec<Section>),
|
Paragraph(Vec<Section>),
|
||||||
@ -311,12 +321,22 @@ pub(crate) struct Section {
|
|||||||
pub(crate) content: Content,
|
pub(crate) content: Content,
|
||||||
}
|
}
|
||||||
|
|
||||||
//impl fmt::Debug for Section {
|
impl fmt::Debug for Section {
|
||||||
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
// let par_header = self.par_header.as_ref().map(String::as_str).unwrap_or("");
|
let par_header = self.par_header.as_ref().map(String::as_str).unwrap_or("");
|
||||||
// write!(f, "{} ({})", self.symb, par_header)
|
write!(f, "{} ({})", self.symb, par_header)
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Section {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
if let Some(header) = &self.par_header {
|
||||||
|
f.write_str(&format!("{} ({})\n{}", self.symb, header, self.content))
|
||||||
|
} else {
|
||||||
|
f.write_str(&format!("{}\n{}", self.symb, self.content))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub(crate) struct ClassifierInstance {
|
pub(crate) struct ClassifierInstance {
|
||||||
@ -415,6 +435,28 @@ pub(crate) enum Content {
|
|||||||
List(Vec<Content>),
|
List(Vec<Content>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Content {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::Text(a) => f.write_str(&format!("{a}")),
|
||||||
|
Self::Item(a) => {
|
||||||
|
let mut ret = String::new();
|
||||||
|
for aa in a {
|
||||||
|
ret.push_str(&format!("{aa}\n"));
|
||||||
|
}
|
||||||
|
f.write_str(&ret)
|
||||||
|
}
|
||||||
|
Self::List(a) => {
|
||||||
|
let mut ret = String::new();
|
||||||
|
for aa in a {
|
||||||
|
ret.push_str(&format!("{aa}\n"));
|
||||||
|
}
|
||||||
|
f.write_str(&ret)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
Loading…
Reference in New Issue
Block a user