mirror of
https://github.com/nushell/nushell.git
synced 2025-08-13 06:58:09 +02:00
Implement exclusive and inclusive ranges with ..< and .. (#2541)
* Implement exclusive and inclusive ranges with .. and ..= This commit adds right-exclusive ranges. The original a..b inclusive syntax was changed to reflect the Rust notation. New a..=b syntax was introduced to have the old behavior. Currently, both a.. and b..= is valid, and it is unclear whether it's valid to impose restrictions. The original issue suggests .. for inclusive and ..< for exclusive ranges, this can be implemented by making simple changes to this commit. * Fix collect tests by changing ranges to ..= * Fix clippy lints in exclusive range matching * Implement exclusive ranges using `..<`
This commit is contained in:
@ -143,7 +143,11 @@ impl PrettyDebug for FormatInlineShape {
|
||||
|
||||
let op = match (left_inclusion, right_inclusion) {
|
||||
(RangeInclusion::Inclusive, RangeInclusion::Inclusive) => "..",
|
||||
_ => unimplemented!("No syntax for ranges that aren't inclusive on the left and inclusive on the right")
|
||||
(RangeInclusion::Inclusive, RangeInclusion::Exclusive) => "..<",
|
||||
_ => unimplemented!(
|
||||
"No syntax for ranges that aren't inclusive on the left and exclusive \
|
||||
or inclusive on the right"
|
||||
),
|
||||
};
|
||||
|
||||
left.clone().format().pretty() + b::operator(op) + right.clone().format().pretty()
|
||||
|
Reference in New Issue
Block a user