ystd 0.0.11

An opinionated and batteries included `std` mirror for convenient, correct code and pleasant error messages
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{error::ReportedError, io::asyncify, prelude::*};

#[instrument(name = "ystd::which::which")]
pub async fn which(
	binary_name: &'static str,
) -> Result<Utf8PathBuf, ReportedError<::which::Error>> {
	let path = move || {
		Ok(::which::which(binary_name)
			.map_err(ReportedError::new)
			.wrap_reported_err(format!("::which::which failed"))?)
	};
	let path = asyncify(path).await?;
	let path = Utf8PathBuf::try_from(path).map_err(|err| ReportedError::empty(Report::new(err)))?;
	Ok(path)
}