Skip to main content

Witness

Struct Witness 

Source
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: usize

Tokens 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

Source

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.

Source

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.

Source

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§

Source§

impl Clone for Witness

Source§

fn clone(&self) -> Witness

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Witness

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Witness

Source§

fn default() -> Witness

Returns the “default value” for a type. Read more
Source§

impl Eq for Witness

Source§

impl PartialEq for Witness

Source§

fn eq(&self, other: &Witness) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Witness

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.