pub struct SourceFileDiffs {
    pub(crate) line_start: BytePos,
    pub(crate) bytes_per_diff: usize,
    pub(crate) num_diffs: usize,
    pub(crate) raw_diffs: Vec<u8>,
}
Expand description

The source file lines in difference list form. This matches the form used within metadata, which saves space by exploiting the fact that the lines list is sorted and individual lines are usually not that long.

We read it directly from metadata and only decode it into Lines form when necessary. This is a significant performance win, especially for small crates where very little of std’s metadata is used.

Fields

line_start: BytePos

Position of the first line. Note that this is always encoded as a BytePos because it is often much larger than any of the differences.

bytes_per_diff: usize

Always 1, 2, or 4. Always as small as possible, while being big enough to hold the length of the longest line in the source file. The 1 case is by far the most common.

num_diffs: usize

The number of diffs encoded in raw_diffs. Always one less than the number of lines in the source file.

raw_diffs: Vec<u8>

The diffs in “raw” form. Each segment of bytes_per_diff length encodes one little-endian diff. Note that they aren’t LEB128 encoded. This makes for much faster decoding. Besides, the bytes_per_diff==1 case is by far the most common, and LEB128 encoding has no effect on that case.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 48 bytes