mirror of
https://github.com/nushell/nushell
synced 2025-01-25 11:25:21 +00:00
19 lines
540 B
Rust
19 lines
540 B
Rust
use nu_parser::Number;
|
|
use nu_protocol::Primitive;
|
|
|
|
pub fn number(number: impl Into<Number>) -> Primitive {
|
|
let number = number.into();
|
|
|
|
match number {
|
|
Number::Int(int) => Primitive::Int(int),
|
|
Number::Decimal(decimal) => Primitive::Decimal(decimal),
|
|
}
|
|
}
|
|
|
|
pub fn style_primitive(primitive: &Primitive) -> &'static str {
|
|
match primitive {
|
|
Primitive::Bytes(0) => "c", // centre 'missing' indicator
|
|
Primitive::Int(_) | Primitive::Bytes(_) | Primitive::Decimal(_) => "r",
|
|
_ => "",
|
|
}
|
|
}
|