mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 03:15:00 +02:00
Add key_timeout config option (#1649)
This commit is contained in:
@ -20,6 +20,7 @@ use indexmap::IndexMap;
|
||||
use nu_errors::ShellError;
|
||||
use nu_source::{AnchorLocation, HasSpan, Span, Spanned, Tag};
|
||||
use num_bigint::BigInt;
|
||||
use num_traits::ToPrimitive;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
use std::time::SystemTime;
|
||||
@ -122,6 +123,19 @@ impl UntaggedValue {
|
||||
}
|
||||
}
|
||||
|
||||
/// Expect this value to be an integer and return it
|
||||
pub fn expect_int(&self) -> i64 {
|
||||
let big_int = match self {
|
||||
UntaggedValue::Primitive(Primitive::Int(int)) => Some(int),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
match big_int.and_then(|i| i.to_i64()) {
|
||||
Some(i) => i,
|
||||
_ => panic!("expect_int assumes that the value must be a integer"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper for creating row values
|
||||
pub fn row(entries: IndexMap<String, Value>) -> UntaggedValue {
|
||||
UntaggedValue::Row(entries.into())
|
||||
|
Reference in New Issue
Block a user