Avoid unsafe in span::Discontinuous::chars
hellux opened this issue · 0 comments
hellux commented
The borrowed spans for inlines right now are quite unsound right now:
fn chars(&self) -> Self::Chars {
unsafe { std::mem::transmute(InlineChars::new(self.src, self.spans.iter().copied())) }
}
We should try to get rid of the unsafe block here. Problem is that the Parser holds a vector of spans and we need to borrow a slice of it from within the Parser. So we get kind of a self-reference.
This doesn't really cause any problems right now, I think, but if we want to e.g. allow cloning the Parser it will be problematic.