Skip to main content

Chunk

Struct Chunk 

Source
pub struct Chunk<T> { /* private fields */ }
Expand description

Represents a contiguous sub-sequence (chunk) of items participating in a diff/patch operation.

Implementations§

Source§

impl<T> Chunk<T>

Source

pub fn new( position: usize, lines: Vec<T>, change_position: Option<Vec<usize>>, ) -> Self

Creates a new Chunk with a starting position, lines, and optional positions of modified lines.

Source

pub fn with_lines(position: usize, lines: Vec<T>) -> Self

Convenience constructor creating a Chunk without granular line-change tracking indices.

Source

pub fn verify_chunk(&self, target: &[T]) -> Result<VerifyChunk, PatchError>
where T: PartialEq,

Verifies that this chunk’s saved lines match the corresponding region in the target slice.

Source

pub fn verify_chunk_at( &self, target: &[T], fuzz: usize, position: usize, ) -> Result<VerifyChunk, PatchError>
where T: PartialEq,

Verifies that this chunk matches the target sequence starting at position, taking fuzz context into account.

Source

pub fn position(&self) -> usize

Returns the zero-based start position of this chunk.

Source

pub fn lines(&self) -> &[T]

Returns a slice reference to the chunk’s lines.

Source

pub fn lines_mut(&mut self) -> &mut Vec<T>

Returns a mutable slice reference to the chunk’s lines.

Source

pub fn set_lines(&mut self, lines: Vec<T>)

Sets or replaces the lines stored inside this chunk.

Source

pub fn change_position(&self) -> Option<&[usize]>

Returns an optional slice reference to the change position indices, if present.

Source

pub fn len(&self) -> usize

Returns the number of lines contained in this chunk.

Source

pub fn size(&self) -> usize

Alias method for len matching common Java/C# diff library APIS.

Source

pub fn is_empty(&self) -> bool

Returns true if this chunk contains no lines.

Source

pub fn last(&self) -> usize

Returns the zero-based index of the last line in the chunk (if non-empty).

Trait Implementations§

Source§

impl<T: Clone> Clone for Chunk<T>

Source§

fn clone(&self) -> Chunk<T>

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<T: Debug> Debug for Chunk<T>

Source§

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

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

impl<'de, T> Deserialize<'de> for Chunk<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Debug> Display for Chunk<T>

Source§

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

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

impl<T: Eq> Eq for Chunk<T>

Source§

impl<T: Hash> Hash for Chunk<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Chunk<T>

Source§

fn eq(&self, other: &Chunk<T>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<T> Serialize for Chunk<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Chunk<T>

Auto Trait Implementations§

§

impl<T> Freeze for Chunk<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Chunk<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Chunk<T>
where Vec<T>: Send,

§

impl<T> Sync for Chunk<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Chunk<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for Chunk<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Chunk<T>
where Vec<T>: UnwindSafe,

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.