Skip to main content

Patched

Struct Patched 

Source
pub struct Patched {
    pub name: String,
    pub dir: PathBuf,
    pub entry: PathBuf,
}
Expand description

A dependency the project took into its tree: the name the manifest declares it under, the directory patch_dir points at, and the directory inside it that require reads. Both paths absolute.

The name is carried beside the directory because it is what a report says. htl’s own layout puts mathx in patches/mathx, but the manifest may name any directory, and a type error in there is the dependency’s name to report either way.

Fields§

§name: String

The [deps] key, which is also the module name require reaches the dependency by — and so the name a diagnostic in the copy is reported under.

§dir: PathBuf

Where patch_dir points, made absolute against the project root. The manifest writes it relative; a walker asked whether it may enter a directory needs the absolute form.

§entry: PathBuf

<dir>/<entry>: the dependency’s own require root inside the copy, the same directory entries/<name> is a link to. require("<name>.x") reads x.tl from here. How it is arrived at is patch_entry’s to say, below; what goes on the search path is search_dir.

Implementations§

Source§

impl Patched

Source

pub fn search_dir(&self) -> PathBuf

The directory to put on the search path so that the copy answers to the dependency’s name.

A directory on the path is consulted as <dir>/<module>, <dir>/<module>/init and <dir>/<module>/<module> (the three templates add_path writes), with the dots of the module name as separators. So the directory that resolves a dependency exactly as .htl/modules/entries does is the one holding entry as a child named after the dependency — which is what the link entries/<name> is, made out of a name and a directory rather than found as one.

There is such a directory whenever the entry is named after the dependency: src/<name> and lua/<name>, the layout most packages have, and the copy root itself for a package whose entry is ., since htl pkg patch writes patches/<dep>. Its parent is the answer, and every name then resolves to the file an install would have resolved it to.

A flat package — entry = "src" holding <name>.tl beside its other modules — has no such directory anywhere, because nothing in the copy is named after the dependency. The entry itself is the answer there: require("<name>") reads <entry>/<name>.tl, which is the file the link resolves it to as well, and require("<name>.sub") does not resolve, since the link reaches that at <entry>/sub.tl and no directory on a path reaches it as <name>/sub. Such a dependency needs its link, and an install is what writes one.

Both go on the path before everything else, which puts them last in it (Htl::apply_project): a name the copy answers is one the project’s own sources, the entry links and every other dependency have already declined, so the flat case’s extra names cannot shadow anything.

Trait Implementations§

Source§

impl Clone for Patched

Source§

fn clone(&self) -> Patched

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 Patched

Source§

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

Formats the value using the given formatter. Read more

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

Source§

impl<T> MaybeSync for T

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 = !

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.