Skip to main content

CdMove

Struct CdMove 

Source
pub struct CdMove<'a> {
    pub target: &'a str,
    pub args: &'a [String],
    pub pwd: &'a Path,
    pub prev: Option<&'a Path>,
    pub dest: Option<&'a Path>,
    pub ctx: &'a Ctx<'a>,
}
Expand description

One attempted (or completed) cd, with everything a clause may need to judge it.

Fields§

§target: &'a str

The first non-option argument of cd: "" for a bare cd, "-" for cd -.

§args: &'a [String]

All arguments of cd, options included, for custom rules.

§pwd: &'a Path

The logical directory the player is in before the move, as the shell reports it.

§prev: Option<&'a Path>

The shell’s previous directory, used to resolve cd - before the move.

§dest: Option<&'a Path>

After the move only: the logical $PWD the shell ended up in.

§ctx: &'a Ctx<'a>

The situation: workspace, section root, home, level.

Implementations§

Source§

impl<'a> CdMove<'a>

Source

pub fn new( ctx: &'a Ctx<'a>, target: &'a str, args: &'a [String], pwd: &'a Path, ) -> Self

A move about to happen: no previous directory, no destination yet.

Source

pub fn with_prev(self, prev: Option<&'a Path>) -> Self

Set the shell’s previous directory (what cd - goes to).

Source

pub fn with_dest(self, dest: &'a Path) -> Self

Set the directory the shell actually ended up in (a move that has happened).

Source

pub fn is_bare(&self) -> bool

True for a bare cd.

Source

pub fn destination(&self) -> Option<PathBuf>

Where the move goes, as the shell’s logical $PWD will read.

After the move this is CdMove::dest as given. Before it, the target is resolved the way cd -L does: "" is $HOME, - is the previous directory, an absolute target is itself, anything else is relative to pwd; then . and .. are resolved lexically (no symlink is followed). None when it cannot be known: cd - without a previous directory, or a relative target with no usable pwd.

Trait Implementations§

Source§

impl<'a> Clone for CdMove<'a>

Source§

fn clone(&self) -> CdMove<'a>

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<'a> Copy for CdMove<'a>

Source§

impl<'a> Debug for CdMove<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CdMove<'a>

§

impl<'a> RefUnwindSafe for CdMove<'a>

§

impl<'a> Send for CdMove<'a>

§

impl<'a> Sync for CdMove<'a>

§

impl<'a> Unpin for CdMove<'a>

§

impl<'a> UnsafeUnpin for CdMove<'a>

§

impl<'a> UnwindSafe for CdMove<'a>

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