forked from extern/nushell
Add support for positive integer ranges
Including support for variables and subexpressions as range bounds.
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
use crate::Span;
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@ -46,3 +48,24 @@ impl Display for Operator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum RangeInclusion {
|
||||
Inclusive,
|
||||
RightExclusive,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct RangeOperator {
|
||||
pub inclusion: RangeInclusion,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Display for RangeOperator {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.inclusion {
|
||||
RangeInclusion::Inclusive => write!(f, ".."),
|
||||
RangeInclusion::RightExclusive => write!(f, "..<"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user