mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:36:00 +02:00
Fix directory change lag (#672)
This commit is contained in:
@ -18,6 +18,7 @@ use sys_locale::get_locale;
|
||||
pub use unit::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::{cmp::Ordering, fmt::Debug};
|
||||
|
||||
use crate::ast::{CellPath, PathMember};
|
||||
@ -173,6 +174,17 @@ impl Value {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_path(&self) -> Result<PathBuf, ShellError> {
|
||||
match self {
|
||||
Value::String { val, .. } => Ok(PathBuf::from(val)),
|
||||
x => Err(ShellError::CantConvert(
|
||||
"path".into(),
|
||||
x.get_type().to_string(),
|
||||
self.span()?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_block(&self) -> Result<BlockId, ShellError> {
|
||||
match self {
|
||||
Value::Block { val, .. } => Ok(*val),
|
||||
|
Reference in New Issue
Block a user