From b3382c66cd01cd306b8bb154ac403f8faabb4fed Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 2 Oct 2023 12:01:07 -0400 Subject: [PATCH] Fix lifetimes on ElispFact. This was listed as a yellow flag on https://quinedot.github.io/rust-learning/pf-shared-nested.html. --- src/compare/elisp_fact.rs | 122 +++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/src/compare/elisp_fact.rs b/src/compare/elisp_fact.rs index 4646f7e..1729f2e 100644 --- a/src/compare/elisp_fact.rs +++ b/src/compare/elisp_fact.rs @@ -60,21 +60,21 @@ use crate::types::Verbatim; use crate::types::VerseBlock; pub(crate) trait ElispFact<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str>; + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str>; } pub(crate) trait GetElispFact<'s> { - fn get_elisp_fact(&'s self) -> &'s dyn ElispFact<'s>; + fn get_elisp_fact<'b>(&'b self) -> &'b dyn ElispFact<'s>; } impl<'s, I: ElispFact<'s>> GetElispFact<'s> for I { - fn get_elisp_fact(&'s self) -> &'s dyn ElispFact<'s> { + fn get_elisp_fact<'b>(&'b self) -> &'b dyn ElispFact<'s> { self } } impl<'s> GetElispFact<'s> for Element<'s> { - fn get_elisp_fact(&'s self) -> &'s dyn ElispFact<'s> { + fn get_elisp_fact<'b>(&'b self) -> &'b dyn ElispFact<'s> { match self { Element::Paragraph(inner) => inner, Element::PlainList(inner) => inner, @@ -103,7 +103,7 @@ impl<'s> GetElispFact<'s> for Element<'s> { } impl<'s> GetElispFact<'s> for Object<'s> { - fn get_elisp_fact(&'s self) -> &'s dyn ElispFact<'s> { + fn get_elisp_fact<'b>(&'b self) -> &'b dyn ElispFact<'s> { match self { Object::Bold(inner) => inner, Object::Italic(inner) => inner, @@ -137,37 +137,37 @@ impl<'s> GetElispFact<'s> for Object<'s> { } impl<'s> ElispFact<'s> for Document<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "org-data".into() } } impl<'s> ElispFact<'s> for Section<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "section".into() } } impl<'s> ElispFact<'s> for Heading<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "headline".into() } } impl<'s> ElispFact<'s> for PlainList<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "plain-list".into() } } impl<'s> ElispFact<'s> for PlainListItem<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "item".into() } } impl<'s> ElispFact<'s> for GreaterBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { match self.name.to_lowercase().as_str() { "center" => "center-block".into(), "quote" => "quote-block".into(), @@ -177,297 +177,297 @@ impl<'s> ElispFact<'s> for GreaterBlock<'s> { } impl<'s> ElispFact<'s> for DynamicBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "dynamic-block".into() } } impl<'s> ElispFact<'s> for FootnoteDefinition<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "footnote-definition".into() } } impl<'s> ElispFact<'s> for Drawer<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "drawer".into() } } impl<'s> ElispFact<'s> for PropertyDrawer<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "property-drawer".into() } } impl<'s> ElispFact<'s> for NodeProperty<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "node-property".into() } } impl<'s> ElispFact<'s> for Table<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "table".into() } } impl<'s> ElispFact<'s> for TableRow<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "table-row".into() } } impl<'s> ElispFact<'s> for Paragraph<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "paragraph".into() } } impl<'s> ElispFact<'s> for TableCell<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "table-cell".into() } } impl<'s> ElispFact<'s> for Comment<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "comment".into() } } impl<'s> ElispFact<'s> for VerseBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "verse-block".into() } } impl<'s> ElispFact<'s> for CommentBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "comment-block".into() } } impl<'s> ElispFact<'s> for ExampleBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "example-block".into() } } impl<'s> ElispFact<'s> for ExportBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "export-block".into() } } impl<'s> ElispFact<'s> for SrcBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "src-block".into() } } impl<'s> ElispFact<'s> for Clock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "clock".into() } } impl<'s> ElispFact<'s> for DiarySexp<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "diary-sexp".into() } } impl<'s> ElispFact<'s> for Planning<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "planning".into() } } impl<'s> ElispFact<'s> for FixedWidthArea<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "fixed-width".into() } } impl<'s> ElispFact<'s> for HorizontalRule<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "horizontal-rule".into() } } impl<'s> ElispFact<'s> for Keyword<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "keyword".into() } } impl<'s> ElispFact<'s> for BabelCall<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "babel-call".into() } } impl<'s> ElispFact<'s> for LatexEnvironment<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "latex-environment".into() } } impl<'s> ElispFact<'s> for Bold<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "bold".into() } } impl<'s> ElispFact<'s> for Italic<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "italic".into() } } impl<'s> ElispFact<'s> for Underline<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "underline".into() } } impl<'s> ElispFact<'s> for StrikeThrough<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "strike-through".into() } } impl<'s> ElispFact<'s> for Code<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "code".into() } } impl<'s> ElispFact<'s> for Verbatim<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "verbatim".into() } } impl<'s> ElispFact<'s> for RegularLink<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "link".into() } } impl<'s> ElispFact<'s> for RadioLink<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "link".into() } } impl<'s> ElispFact<'s> for RadioTarget<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "radio-target".into() } } impl<'s> ElispFact<'s> for PlainLink<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "link".into() } } impl<'s> ElispFact<'s> for AngleLink<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "link".into() } } impl<'s> ElispFact<'s> for OrgMacro<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "macro".into() } } impl<'s> ElispFact<'s> for Entity<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "entity".into() } } impl<'s> ElispFact<'s> for LatexFragment<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "latex-fragment".into() } } impl<'s> ElispFact<'s> for ExportSnippet<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "export-snippet".into() } } impl<'s> ElispFact<'s> for FootnoteReference<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "footnote-reference".into() } } impl<'s> ElispFact<'s> for Citation<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "citation".into() } } impl<'s> ElispFact<'s> for CitationReference<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "citation-reference".into() } } impl<'s> ElispFact<'s> for InlineBabelCall<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "inline-babel-call".into() } } impl<'s> ElispFact<'s> for InlineSourceBlock<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "inline-src-block".into() } } impl<'s> ElispFact<'s> for LineBreak<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "line-break".into() } } impl<'s> ElispFact<'s> for Target<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "target".into() } } impl<'s> ElispFact<'s> for StatisticsCookie<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "statistics-cookie".into() } } impl<'s> ElispFact<'s> for Subscript<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "subscript".into() } } impl<'s> ElispFact<'s> for Superscript<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "superscript".into() } } impl<'s> ElispFact<'s> for Timestamp<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { "timestamp".into() } } impl<'s> ElispFact<'s> for PlainText<'s> { - fn get_elisp_name(&'s self) -> Cow<'s, str> { + fn get_elisp_name<'b>(&'b self) -> Cow<'s, str> { // plain text from upstream emacs does not actually have a name but this is included here to make rendering the status diff easier. "plain-text".into() }