mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add comments
This commit is contained in:
parent
30cac851e7
commit
5f5fb4e502
@ -48,12 +48,15 @@ pub fn prefix<'a, I>(iter: I, available_width: usize, delimiter: &str) -> Prefix
|
|||||||
let delimiter_width = delimiter.width();
|
let delimiter_width = delimiter.width();
|
||||||
let delimiter_len = delimiter.len();
|
let delimiter_len = delimiter.len();
|
||||||
|
|
||||||
|
// `current_width` is the width of everything
|
||||||
|
// before the next token, including any space.
|
||||||
let mut current_width = 0;
|
let mut current_width = 0;
|
||||||
let sum = iter.take_while(|token| {
|
let sum = iter.take_while(|token| {
|
||||||
let width = token.width();
|
let width = token.width();
|
||||||
if current_width + width > available_width {
|
if current_width + width > available_width {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
// Include the delimiter after this token.
|
||||||
current_width += width;
|
current_width += width;
|
||||||
current_width += delimiter_width;
|
current_width += delimiter_width;
|
||||||
true
|
true
|
||||||
@ -66,6 +69,7 @@ pub fn prefix<'a, I>(iter: I, available_width: usize, delimiter: &str) -> Prefix
|
|||||||
// but only if the iterator was non empty.
|
// but only if the iterator was non empty.
|
||||||
let length = sum.saturating_sub(delimiter_len);
|
let length = sum.saturating_sub(delimiter_len);
|
||||||
|
|
||||||
|
// `current_width` includes a delimiter after the last token
|
||||||
debug_assert!(current_width <= available_width + delimiter_width);
|
debug_assert!(current_width <= available_width + delimiter_width);
|
||||||
|
|
||||||
Prefix {
|
Prefix {
|
||||||
|
Loading…
Reference in New Issue
Block a user