pub struct Witness {
pub changes: Vec<Change>,
pub edits: usize,
}Expand description
The substitutions that turn one occurrence into another.
Fields§
§changes: Vec<Change>Each distinct change, in the order first seen.
edits: usizeTokens on either side that had no counterpart in the other.
A substitution is one token standing where another stood. These are the rest: the statement one occurrence has and the other does not, the cast added on one side only. Counted rather than described, because a rule over a witness cares whether the two bodies do the same work, and that question is answered by there being none of these.
Implementations§
Source§impl Witness
impl Witness
Sourcepub fn one_width_apart(&self) -> Option<(&'static str, &'static str)>
pub fn one_width_apart(&self) -> Option<(&'static str, &'static str)>
The one width swap that explains every change, if there is one.
Some(("32", "64")) says every token that differs does so by having
that width in place of the other, everywhere it occurs: u32/u64,
read32/read64, XXH32_hash_t/XXH64_hash_t. That is what a set of
routines written once per width looks like from the outside, and it is
not what a copied function looks like — a copy renamed by hand changes
names that have nothing to do with each other.
None when the changes are not all one swap, and for a witness with no
changes at all: two occurrences that differ in nothing were not written
one per width, they are the same text.
Sourcepub fn written_once_per_width(&self) -> bool
pub fn written_once_per_width(&self) -> bool
Whether these two occurrences read as one routine written once per width.
The two questions above, asked together, which is the only way either is worth asking. Kept here rather than at each call site so the rule the engine acts on and the rule the corpus is measured against cannot drift apart.
Nothing is asked about Self::edits: a routine written for the wider
type does work the narrower one has no need of, and bounding that would
mean choosing a number no measurement over real code has supported.
Sourcepub fn touches_a_literal(&self) -> bool
pub fn touches_a_literal(&self) -> bool
Whether any change replaced a literal.
A changed constant is a changed answer. Two bodies alike but for the number they compare against are two decisions, however alike they read, so no rule that sets duplication aside should reach them.
Trait Implementations§
impl Eq for Witness
impl StructuralPartialEq for Witness
Auto Trait Implementations§
impl Freeze for Witness
impl RefUnwindSafe for Witness
impl Send for Witness
impl Sync for Witness
impl Unpin for Witness
impl UnsafeUnpin for Witness
impl UnwindSafe for Witness
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.