Struct which::WhichConfig

source ·
pub struct WhichConfig { /* private fields */ }
Expand description

A wrapper containing all functionality in this crate.

Implementations§

source§

impl WhichConfig

source

pub fn new() -> Self

source

pub fn system_cwd(self, use_cwd: bool) -> Self

Whether or not to use the current working directory. true by default.

§Panics

If regex was set previously, and you’ve just passed in use_cwd: true, this will panic.

source

pub fn custom_cwd(self, cwd: PathBuf) -> Self

Sets a custom path for resolving relative paths.

§Panics

If regex was set previously, this will panic.

source

pub fn regex(self, regex: ()) -> Self

Sets the path name regex to search for. You MUST call this, or Self::binary_name prior to searching.

When Regex is disabled this function takes the unit type as a stand in. The parameter will change when Regex is enabled.

§Panics

If the regex feature wasn’t turned on for this crate this will always panic. Additionally if a cwd (aka current working directory) or binary_name was set previously, this will panic, as those options are incompatible with regex.

source

pub fn binary_name(self, name: OsString) -> Self

Sets the path name to search for. You MUST call this, or Self::regex prior to searching.

§Panics

If a regex was set previously this will panic as this is not compatible with regex.

source

pub fn custom_path_list(self, custom_path_list: OsString) -> Self

Uses the given string instead of the PATH env variable.

source

pub fn system_path_list(self) -> Self

Uses the PATH env variable. Enabled by default.

source

pub fn first_result(self) -> Result<PathBuf>

Finishes configuring, runs the query and returns the first result.

source

pub fn all_results(self) -> Result<impl Iterator<Item = PathBuf>>

Finishes configuring, runs the query and returns all results.

Trait Implementations§

source§

impl Default for WhichConfig

source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.