pub struct InternedInput<T>{
pub before: Vec<Token>,
pub after: Vec<Token>,
pub interner: Interner<T>,
}
blob
only.Expand description
Two lists of interned tokens that can be compared with the diff
function.
A token represents the smallest possible unit of change during a diff. For text this is usually a line, a word or a single character. All algorithms operate on interned tokens instead of using the token data directly. This allows for much better performance by amortizing the cost hashing/equality.
While you can intern tokens yourself it is strongly recommended to use InternedInput
module.
Fields§
§before: Vec<Token>
§after: Vec<Token>
§interner: Interner<T>
Implementations§
Source§impl<T> InternedInput<T>
impl<T> InternedInput<T>
pub fn new<I>(before: I, after: I) -> InternedInput<T>where
I: TokenSource<Token = T>,
Sourcepub fn update_before(&mut self, input: impl Iterator<Item = T>)
pub fn update_before(&mut self, input: impl Iterator<Item = T>)
replaces self.before
wtih the iterned Tokens yielded by input
Note that this does not erase any tokens from the interner and might therefore be considered
a memory leak. If this function is called often over a long_running process
consider clearing the interner with clear
.
Sourcepub fn update_after(&mut self, input: impl Iterator<Item = T>)
pub fn update_after(&mut self, input: impl Iterator<Item = T>)
replaces self.before
wtih the iterned Tokens yielded by input
Note that this does not erase any tokens from the interner and might therefore be considered
a memory leak. If this function is called often over a long_running process
consider clearing the interner with clear
or
erase_tokens_after
.