Created
October 27, 2019 02:32
-
-
Save martinmroz/9ecf4bb0b843b3d71f2ed362ff3ea906 to your computer and use it in GitHub Desktop.
Span joining two Flux instances together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn span(self, rhs: Flux) -> Self { | |
let words = { | |
// If the span is formed along a non-space to non-space boundary the word count is one less than the sum. | |
if let (CharType::NotSpace, CharType::NotSpace) = (self.rightmost_char_type, rhs.leftmost_char_type) { | |
self.words + rhs.words - 1 | |
} else { | |
self.words + rhs.words | |
} | |
}; | |
Flux::new(self.leftmost_char_type, words, self.lines + rhs.lines, rhs.rightmost_char_type) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment