Skip to content

Commit

Permalink
Update rendering of empty ranges to not show inc_lower (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke authored Dec 11, 2023
1 parent a3b4401 commit f179d64
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/print/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,23 +274,21 @@ impl FormatExt for Value {
if !rng.is_empty() {
rng.upper().map(|x| &**x).format(prn)?;
prn.comma()?;
}

// These fields are all optional, so we omit them
// when they have the default values.
if !rng.inc_lower() {
prn.tuple_field("inc_lower")?;
prn.const_bool(rng.inc_lower())?;
prn.comma()?;
}

if rng.inc_upper() {
prn.tuple_field("inc_upper")?;
prn.const_bool(rng.inc_upper())?;
prn.comma()?;
}

if rng.is_empty() {
// These fields are all optional, so we omit them
// when they have the default values.
if !rng.inc_lower() {
prn.tuple_field("inc_lower")?;
prn.const_bool(rng.inc_lower())?;
prn.comma()?;
}

if rng.inc_upper() {
prn.tuple_field("inc_upper")?;
prn.const_bool(rng.inc_upper())?;
prn.comma()?;
}
} else {
prn.tuple_field("empty")?;
prn.const_bool(rng.is_empty())?;
prn.comma()?;
Expand Down

0 comments on commit f179d64

Please sign in to comment.