/// May allow the compiler to consolidate the `Drop`s for `msg`, reducing code size compared to /// `styled.push_str(&msg)` pub(crate) fn push_string(&mutself, msg: String) { self.0.push_str(&msg);
}
letmut last = 0; letmut wrapper = crate::output::textwrap::wrap_algorithms::LineWrapper::new(hard_width);
for content in self.iter_text() { // Preserve styling let current = content.as_ptr() as usize - self.0.as_str().as_ptr() as usize; if last != current {
new.push_str(&self.0.as_str()[last..current]);
}
last = current + content.len();
for (i, line) in content.split_inclusive('\n').enumerate() { if0 < i { // reset char count on newline, skipping the start as we might have carried // over from a prior block of styled text
wrapper.reset();
} let line = crate::output::textwrap::word_separators::find_words_ascii_space(line)
.collect::<Vec<_>>();
new.extend(wrapper.wrap(line));
}
} if last != self.0.len() {
new.push_str(&self.0.as_str()[last..]);
}
new = new.trim_end().to_owned();
self.0 = new;
}
#[inline(never)] #[cfg(feature = "help")] pub(crate) fn display_width(&self) -> usize { letmut width = 0;
for c in self.iter_text() {
width += crate::output::display_width(c);
}
width
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.