Closed
Description
See: #87479
So, I believe #89970 broke my code kas-text (nightly rustc + --feature gat
).
Let's focus on the iter function. The first thing to realize is that we know that Self: 'a because of &'a self
This isn't true in general, though it may be in specific instances. My code (reduced) exemplifies this perfectly:
pub trait FormattableText: std::fmt::Debug {
type FontTokenIter<'a>: Iterator<Item = FontToken>;
fn font_tokens<'a>(&'a self, dpp: f32, pt_size: f32) -> Self::FontTokenIter<'a>;
}
impl<'t> FormattableText for &'t str {
type FontTokenIter<'a> = std::iter::Empty<FontToken>;
fn font_tokens<'a>(&'a self, _: f32, _: f32) -> Self::FontTokenIter<'a> {
std::iter::empty()
}
}
Here, font_tokens
may return an iterator over an instance of Self
... but it also may not (&str
does not have any formatting). A possible workaround in the impl is to write a custom iterator with a reference to the &str
anyway, but this seems unnecessary.