Skip to content

Instantly share code, notes, and snippets.

@martinmroz
Created October 27, 2019 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinmroz/9ecf4bb0b843b3d71f2ed362ff3ea906 to your computer and use it in GitHub Desktop.
Save martinmroz/9ecf4bb0b843b3d71f2ed362ff3ea906 to your computer and use it in GitHub Desktop.
Span joining two Flux instances together
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