forked from extern/nushell
Make the default int an i64 (#3428)
* Make the default int an i64 * fmt * Fix random integer * Treat pids as i64 for now
This commit is contained in:
@ -439,6 +439,10 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Int(int)),
|
||||
..
|
||||
} => visit::<Tagged<i64>, _>(int.tagged(tag), name, fields, visitor),
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::BigInt(int)),
|
||||
..
|
||||
} => {
|
||||
let i: i64 = int.tagged(value.val.tag).coerce_into("converting to i64")?;
|
||||
visit::<Tagged<i64>, _>(i.tagged(tag), name, fields, visitor)
|
||||
|
@ -212,7 +212,10 @@ fn evaluate_literal(literal: &hir::Literal, span: Span) -> Value {
|
||||
.into_value(span)
|
||||
}
|
||||
hir::Literal::Number(int) => match int {
|
||||
nu_protocol::hir::Number::Int(i) => UntaggedValue::int(i.clone()).into_value(span),
|
||||
nu_protocol::hir::Number::BigInt(i) => {
|
||||
UntaggedValue::big_int(i.clone()).into_value(span)
|
||||
}
|
||||
nu_protocol::hir::Number::Int(i) => UntaggedValue::int(*i).into_value(span),
|
||||
nu_protocol::hir::Number::Decimal(d) => {
|
||||
UntaggedValue::decimal(d.clone()).into_value(span)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use nu_protocol::{
|
||||
hir::CapturedBlock, ColumnPath, Dictionary, Primitive, Range, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::{Tagged, TaggedItem};
|
||||
use num_bigint::BigInt;
|
||||
|
||||
pub trait FromValue: Sized {
|
||||
fn from_value(v: &Value) -> Result<Self, ShellError>;
|
||||
@ -24,12 +25,12 @@ impl FromValue for num_bigint::BigInt {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Int(i)),
|
||||
..
|
||||
}
|
||||
| Value {
|
||||
} => Ok(BigInt::from(*i)),
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(i)),
|
||||
..
|
||||
}
|
||||
| Value {
|
||||
} => Ok(BigInt::from(*i)),
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Duration(i)),
|
||||
..
|
||||
} => Ok(i.clone()),
|
||||
|
Reference in New Issue
Block a user