Skip to main content

IndentBlock

Struct IndentBlock 

Source
pub struct IndentBlock {
    pub col: u16,
    pub start_line: u32,
    pub end_line: u32,
}
Expand description

One indent guide: a display column, and the inclusive line range it spans.

start_line is the region’s opener and end_line its closer, both included. Neither is necessarily painted — IndentBlock::paints_on tests that — but both belong to the range because the active block under a cursor sitting on if c { is the block that line opens, and the block under a cursor on the matching } is the one it closes. One range serves the extent question and the membership question.

Fields§

§col: u16

Display column the guide occupies.

§start_line: u32

Opener line, inclusive.

§end_line: u32

Closer line, inclusive.

Implementations§

Source§

impl IndentBlock

Source

pub fn paints_on(&self, line: u32, line_depth: Option<u16>) -> bool

Whether this block’s guide is drawn on line.

The single predicate the whole feature rests on:

in range, and (the line is blank or the guide’s column is strictly left of where the line’s text starts).

The second arm is what keeps a guide out of a cell that holds text — on fn f() { the column-0 guide fails 0 < 0, and on the matching } it fails for the same reason. The first arm is what carries a guide through a blank line inside a block.

Because the producer applies this before publishing, a published guide mark always lands on a blank cell, and no renderer needs a don’t-overwrite-text guard.

Source

pub fn contains(&self, line: u32) -> bool

Whether line is inside this block at all, painted or not. The membership test the active-block pick uses.

Trait Implementations§

Source§

impl Clone for IndentBlock

Source§

fn clone(&self) -> IndentBlock

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 Copy for IndentBlock

Source§

impl Debug for IndentBlock

Source§

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

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

impl Eq for IndentBlock

Source§

impl PartialEq for IndentBlock

Source§

fn eq(&self, other: &IndentBlock) -> 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 IndentBlock

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
§

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

§

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> 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.