Skip to main content

Lens

Struct Lens 

Source
pub struct Lens { /* private fields */ }
Expand description

Everything that decides whether a claim is on screen.

Cloned into every mark, which is why it is a value rather than a handle into the view: a mark has to keep meaning what the reader could see when they made it, and a mark holding a reference to the current view would mean the opposite of that.

Implementations§

Source§

impl Lens

Source

pub fn of(tiers: Tiers, kinds: Kinds) -> Self

A lens on the two axes directly, which is the general door: Lens::showing is the preset shorthand over it.

Source

pub fn showing(preset: Preset) -> Self

The lens a preset names.

Source

pub fn matching(self, pattern: Option<Regex>) -> Self

The same lens with pattern over it, or with none.

Source

pub fn tiers(&self) -> Tiers

Which tiers are on screen.

Source

pub fn kinds(&self) -> Kinds

Which kinds are.

Source

pub fn with_tiers(self, tiers: Tiers) -> Self

The same lens with the tier axis moved, and the kind axis untouched.

The two editors exist so that the axes are independently reachable by a reader, not only inside this file: a model that can express “every cache a rule named” while no key can reach it is not expressible in any sense the request meant.

Source

pub fn with_kinds(self, kinds: Kinds) -> Self

The same lens with the kind axis moved, and the tier axis untouched.

Source

pub fn files(&self) -> bool

Whether gitignored files are on screen.

§Why an axis of its own rather than a third tier

A gitignored file is a tier-two claim, so a third value on the tier axis is the first idea and it does not survive the presets. Each step of f’s cycle moves exactly one axis, and all — “everything the scan found” — would have to widen the tier axis and the kind axis together to reach files. The / pattern already had this shape and was resolved the same way: it decides what is on screen, it is orthogonal to both axes, and no preset touches it. Files are the same, which also means turning them on is not undone by cycling the view.

It is independently reachable, which is what the request asked for in so many words: i toggles this and nothing else, so gitignored files come and go without disturbing gitignored directories.

Source

pub fn with_files(self, files: bool) -> Self

The same lens showing, or not showing, gitignored files. Both other axes untouched.

Source

pub fn preset(&self) -> Option<Preset>

Which preset this lens sits on, if it sits on one.

Unambiguous, because the four presets occupy four distinct points — which is what the footer needs in order to name a view honestly, and it is why nothing has to remember which step of the cycle the reader took to get here. A lens the axis keys built lands off all four and says so.

The pattern is deliberately not consulted, and neither is the files axis: both narrow or widen whatever the two axes left, so dependencies with a pattern over it and files showing beside it is still dependencies.

Source

pub fn axes_label(&self) -> String

How the footer spells the axes when the reader has moved off every preset.

The files axis is named only when it is on, and that asymmetry is deliberate: off is where every view starts, so saying it everywhere would spend a third of the line on the absence of something. When it is on it changes what a row means, so it is said.

Source

pub fn pattern(&self) -> Option<&str>

The pattern in force, if any.

Source

pub fn is_everything(&self) -> bool

Whether this lens hides nothing at all, which is the fast path the whole front end takes when a reader has not narrowed anything.

Note that no preset reaches it: all widens both axes and leaves files where the reader put them, so a run that has never pressed i is narrowed however far f has been cycled. That is what the header’s out-of-view count is for.

Source

pub fn matches(&self, hit: &Hit) -> bool

Whether this claim is on screen.

The three axes are visibly independent here, which is the whole reason for the shape. Where a claim came from decides one of them — a rule, the gitignore fallback, or the fallback on a file — and what it is decides the kind axis, whoever found it. That second half is what lets .env files be narrowed to on their own without a mode anybody had to anticipate, and it leaves the tier-two directory judged by the tier axis and never by the kind axis, since it has no kind to judge.

Source

pub fn describe(&self) -> String

How the confirmation names this lens, when it has to say what a hidden entry is hidden by. Both halves, because either can be the one doing the hiding.

Trait Implementations§

Source§

impl Clone for Lens

Source§

fn clone(&self) -> Lens

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 Lens

Source§

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

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

impl Default for Lens

Source§

fn default() -> Self

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

impl Eq for Lens

Source§

impl Hash for Lens

Source§

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

Exactly what Lens::eq reads, in the same order, because a hash that disagreed with equality is a lens that changed without anybody watching it being told — and super::treemap watches this one to decide whether a picture is still the right one. The pattern goes in as its source text for equality’s own reason.

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 PartialEq for Lens

Source§

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

By what it shows. Regex has no equality of its own, and the pattern is the only honest stand-in — two engines compiled from one string accept the same paths.

1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Freeze for Lens

§

impl RefUnwindSafe for Lens

§

impl Send for Lens

§

impl Sync for Lens

§

impl Unpin for Lens

§

impl UnsafeUnpin for Lens

§

impl UnwindSafe for Lens

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.