Add some more cell path support for fun (#316)

This commit is contained in:
JT 2021-11-09 20:13:05 +13:00 committed by GitHub
parent 6f4993618d
commit e1468c0440
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -267,6 +267,23 @@ impl Value {
return Err(ShellError::AccessBeyondEnd(val.len(), *origin_span));
}
}
Value::Binary { val, .. } => {
if let Some(item) = val.get(*count) {
current = Value::Int {
val: *item as i64,
span: *origin_span,
};
} else {
return Err(ShellError::AccessBeyondEnd(val.len(), *origin_span));
}
}
Value::Range { val, .. } => {
if let Some(item) = val.clone().into_range_iter()?.nth(*count) {
current = item.clone();
} else {
return Err(ShellError::AccessBeyondEndOfStream(*origin_span));
}
}
x => {
return Err(ShellError::IncompatiblePathAccess(
format!("{}", x.get_type()),