mirror of
https://github.com/nushell/nushell.git
synced 2025-01-27 08:38:44 +01:00
add ability to create PathBuf from string to avoid type mismatch
This commit is contained in:
parent
17ad07ce27
commit
e09160e80d
@ -817,6 +817,7 @@ impl Tagged<Value> {
|
|||||||
pub(crate) fn as_path(&self) -> Result<PathBuf, ShellError> {
|
pub(crate) fn as_path(&self) -> Result<PathBuf, ShellError> {
|
||||||
match self.item() {
|
match self.item() {
|
||||||
Value::Primitive(Primitive::Path(path)) => Ok(path.clone()),
|
Value::Primitive(Primitive::Path(path)) => Ok(path.clone()),
|
||||||
|
Value::Primitive(Primitive::String(path_str)) => Ok(PathBuf::from(&path_str).clone()),
|
||||||
other => Err(ShellError::type_error(
|
other => Err(ShellError::type_error(
|
||||||
"Path",
|
"Path",
|
||||||
other.type_name().tagged(self.tag()),
|
other.type_name().tagged(self.tag()),
|
||||||
|
Loading…
Reference in New Issue
Block a user