Fix lifetimes on ElispFact.

This was listed as a yellow flag on https://quinedot.github.io/rust-learning/pf-shared-nested.html.
This commit is contained in:
Tom Alexander 2023-10-02 12:01:07 -04:00
parent 2a003b85fd
commit b3382c66cd
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -60,21 +60,21 @@ use crate::types::Verbatim;
use crate::types::VerseBlock; use crate::types::VerseBlock;
pub(crate) trait ElispFact<'s> { 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> { 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 { 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 self
} }
} }
impl<'s> GetElispFact<'s> for Element<'s> { 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 { match self {
Element::Paragraph(inner) => inner, Element::Paragraph(inner) => inner,
Element::PlainList(inner) => inner, Element::PlainList(inner) => inner,
@ -103,7 +103,7 @@ impl<'s> GetElispFact<'s> for Element<'s> {
} }
impl<'s> GetElispFact<'s> for Object<'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 { match self {
Object::Bold(inner) => inner, Object::Bold(inner) => inner,
Object::Italic(inner) => inner, Object::Italic(inner) => inner,
@ -137,37 +137,37 @@ impl<'s> GetElispFact<'s> for Object<'s> {
} }
impl<'s> ElispFact<'s> for Document<'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() "org-data".into()
} }
} }
impl<'s> ElispFact<'s> for Section<'s> { 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() "section".into()
} }
} }
impl<'s> ElispFact<'s> for Heading<'s> { 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() "headline".into()
} }
} }
impl<'s> ElispFact<'s> for PlainList<'s> { 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() "plain-list".into()
} }
} }
impl<'s> ElispFact<'s> for PlainListItem<'s> { 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() "item".into()
} }
} }
impl<'s> ElispFact<'s> for GreaterBlock<'s> { 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() { match self.name.to_lowercase().as_str() {
"center" => "center-block".into(), "center" => "center-block".into(),
"quote" => "quote-block".into(), "quote" => "quote-block".into(),
@ -177,297 +177,297 @@ impl<'s> ElispFact<'s> for GreaterBlock<'s> {
} }
impl<'s> ElispFact<'s> for DynamicBlock<'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() "dynamic-block".into()
} }
} }
impl<'s> ElispFact<'s> for FootnoteDefinition<'s> { 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() "footnote-definition".into()
} }
} }
impl<'s> ElispFact<'s> for Drawer<'s> { 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() "drawer".into()
} }
} }
impl<'s> ElispFact<'s> for PropertyDrawer<'s> { 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() "property-drawer".into()
} }
} }
impl<'s> ElispFact<'s> for NodeProperty<'s> { 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() "node-property".into()
} }
} }
impl<'s> ElispFact<'s> for Table<'s> { 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() "table".into()
} }
} }
impl<'s> ElispFact<'s> for TableRow<'s> { 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() "table-row".into()
} }
} }
impl<'s> ElispFact<'s> for Paragraph<'s> { 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() "paragraph".into()
} }
} }
impl<'s> ElispFact<'s> for TableCell<'s> { 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() "table-cell".into()
} }
} }
impl<'s> ElispFact<'s> for Comment<'s> { 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() "comment".into()
} }
} }
impl<'s> ElispFact<'s> for VerseBlock<'s> { 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() "verse-block".into()
} }
} }
impl<'s> ElispFact<'s> for CommentBlock<'s> { 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() "comment-block".into()
} }
} }
impl<'s> ElispFact<'s> for ExampleBlock<'s> { 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() "example-block".into()
} }
} }
impl<'s> ElispFact<'s> for ExportBlock<'s> { 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() "export-block".into()
} }
} }
impl<'s> ElispFact<'s> for SrcBlock<'s> { 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() "src-block".into()
} }
} }
impl<'s> ElispFact<'s> for Clock<'s> { 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() "clock".into()
} }
} }
impl<'s> ElispFact<'s> for DiarySexp<'s> { 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() "diary-sexp".into()
} }
} }
impl<'s> ElispFact<'s> for Planning<'s> { 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() "planning".into()
} }
} }
impl<'s> ElispFact<'s> for FixedWidthArea<'s> { 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() "fixed-width".into()
} }
} }
impl<'s> ElispFact<'s> for HorizontalRule<'s> { 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() "horizontal-rule".into()
} }
} }
impl<'s> ElispFact<'s> for Keyword<'s> { 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() "keyword".into()
} }
} }
impl<'s> ElispFact<'s> for BabelCall<'s> { 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() "babel-call".into()
} }
} }
impl<'s> ElispFact<'s> for LatexEnvironment<'s> { 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() "latex-environment".into()
} }
} }
impl<'s> ElispFact<'s> for Bold<'s> { 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() "bold".into()
} }
} }
impl<'s> ElispFact<'s> for Italic<'s> { 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() "italic".into()
} }
} }
impl<'s> ElispFact<'s> for Underline<'s> { 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() "underline".into()
} }
} }
impl<'s> ElispFact<'s> for StrikeThrough<'s> { 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() "strike-through".into()
} }
} }
impl<'s> ElispFact<'s> for Code<'s> { 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() "code".into()
} }
} }
impl<'s> ElispFact<'s> for Verbatim<'s> { 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() "verbatim".into()
} }
} }
impl<'s> ElispFact<'s> for RegularLink<'s> { 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() "link".into()
} }
} }
impl<'s> ElispFact<'s> for RadioLink<'s> { 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() "link".into()
} }
} }
impl<'s> ElispFact<'s> for RadioTarget<'s> { 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() "radio-target".into()
} }
} }
impl<'s> ElispFact<'s> for PlainLink<'s> { 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() "link".into()
} }
} }
impl<'s> ElispFact<'s> for AngleLink<'s> { 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() "link".into()
} }
} }
impl<'s> ElispFact<'s> for OrgMacro<'s> { 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() "macro".into()
} }
} }
impl<'s> ElispFact<'s> for Entity<'s> { 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() "entity".into()
} }
} }
impl<'s> ElispFact<'s> for LatexFragment<'s> { 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() "latex-fragment".into()
} }
} }
impl<'s> ElispFact<'s> for ExportSnippet<'s> { 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() "export-snippet".into()
} }
} }
impl<'s> ElispFact<'s> for FootnoteReference<'s> { 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() "footnote-reference".into()
} }
} }
impl<'s> ElispFact<'s> for Citation<'s> { 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() "citation".into()
} }
} }
impl<'s> ElispFact<'s> for CitationReference<'s> { 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() "citation-reference".into()
} }
} }
impl<'s> ElispFact<'s> for InlineBabelCall<'s> { 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() "inline-babel-call".into()
} }
} }
impl<'s> ElispFact<'s> for InlineSourceBlock<'s> { 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() "inline-src-block".into()
} }
} }
impl<'s> ElispFact<'s> for LineBreak<'s> { 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() "line-break".into()
} }
} }
impl<'s> ElispFact<'s> for Target<'s> { 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() "target".into()
} }
} }
impl<'s> ElispFact<'s> for StatisticsCookie<'s> { 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() "statistics-cookie".into()
} }
} }
impl<'s> ElispFact<'s> for Subscript<'s> { 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() "subscript".into()
} }
} }
impl<'s> ElispFact<'s> for Superscript<'s> { 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() "superscript".into()
} }
} }
impl<'s> ElispFact<'s> for Timestamp<'s> { 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() "timestamp".into()
} }
} }
impl<'s> ElispFact<'s> for PlainText<'s> { 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 from upstream emacs does not actually have a name but this is included here to make rendering the status diff easier.
"plain-text".into() "plain-text".into()
} }