chiark / gitweb /
Add a trait TextFragmentOneLine.
authorSimon Tatham <anakin@pobox.com>
Thu, 11 Jan 2024 17:55:20 +0000 (17:55 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 12 Jan 2024 12:52:04 +0000 (12:52 +0000)
commit9b22210139d8fe96c71ce005eccfbe3c8b4e4267
tree143ab2daf7b0c51a5d2212cbdf660759c3053519
parent2176e02c9036e79cad6c0061e18e603b69762582
Add a trait TextFragmentOneLine.

This is a slight refinement of ordinary TextFragment, to be
implemented by types that render to exactly one line of text always,
as opposed to being able to render to 0 or to more than one. The idea
is that if a type implements this trait, then the compiler can _know_
there's one line of text coming out of its render method, instead of
having to call .iter().exactly_one().unwrap() and think hard about
whether I'm risking a runtime failure.

I could implement this trait for a lot more things in text.rs, but for
the moment, I'm only bothering to put it on the one that I need it for
right now.
src/text.rs