Trait lifetime issues.

This commit is contained in:
Tom Alexander
2023-10-11 11:17:01 -04:00
parent bc4c09c546
commit 63614841e8
3 changed files with 39 additions and 10 deletions

View File

@@ -0,0 +1,38 @@
use crate::types::Keyword;
use crate::types::Object;
use crate::types::PlainList;
pub struct AffiliatedKeyword<'s> {
name: &'s str,
}
pub enum AffiliatedKeywordValue<'s> {
SingleString(&'s str),
ListOfStrings(Vec<&'s str>),
ListOfObjects(Vec<Object<'s>>),
}
pub trait GetAffiliatedKeywords<'s> {
type ItemIterator: Iterator<Item = &'s Keyword<'s>>;
fn get_affiliated_keywords<'r: 's>(&'r self) -> Self::ItemIterator;
}
pub trait HandleAffiliatedKeywords<'s> {
fn get_stuff(&self) -> &'s str;
}
impl<'s> GetAffiliatedKeywords<'s> for PlainList<'s> {
type ItemIterator = std::slice::Iter<'s, Keyword<'s>>;
fn get_affiliated_keywords<'r: 's>(&'r self) -> Self::ItemIterator {
self.affiliated_keywords.iter()
}
}
impl<'s, I: GetAffiliatedKeywords<'s>> HandleAffiliatedKeywords<'s> for I {
fn get_stuff(&self) -> &'s str {
self.get_affiliated_keywords().count();
todo!()
}
}

View File

@@ -1,3 +1,4 @@
mod affiliated_keyword;
mod angle_link;
mod babel_call;
mod citation;