Struct imara_diff::intern::InternedInput
source · pub struct InternedInput<T: Eq + Hash> {
pub before: Vec<Token>,
pub after: Vec<Token>,
pub interner: Interner<T>,
}
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: Eq + Hash> InternedInput<T>
impl<T: Eq + Hash> InternedInput<T>
pub fn new<I: TokenSource<Token = T>>(before: I, after: I) -> Self
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
.