Skip to content

Add support for number ranges #602

Merged
juntyr merged 75 commits into
ron-rs:masterfrom
Ztry8:master
Jun 4, 2026
Merged

Add support for number ranges #602
juntyr merged 75 commits into
ron-rs:masterfrom
Ztry8:master

Conversation

@Ztry8

@Ztry8 Ztry8 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

This PR implements #601: support for number ranges in RON.

It's just syntactic sugar for structures with fields start, end or start, last.
It supports both std::ops and core::range.

Example:

let ranges = RangeTest {
    a: 0..5,
    b: 1..=3,
    c: 0.6..4.3,
    d: 0.3..=5.7,
};

let ser = ron::to_string(&ranges).unwrap();
assert_eq!(ser, "(a:0..5,b:1..=3,c:0.6..4.3,d:0.3..=5.7)");

let de: RangeTest = ron::from_str(&ser).unwrap();
assert_eq!(de, ranges);

Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs
Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs Outdated
Comment thread src/ser/mod.rs Outdated
Comment thread tests/601_support_for_number_ranges.rs Outdated
@juntyr

juntyr commented Apr 25, 2026

Copy link
Copy Markdown
Member

Thanks @Ztry8 for prototyping this feature!

@juntyr

juntyr commented Apr 25, 2026

Copy link
Copy Markdown
Member

Also, this addition will need to be documented in the grammar

@Ztry8

Ztry8 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

Thank you! I've already started working about this

@Ztry8

Ztry8 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, is everything fine now? What should I put into CHANGELOG.md? Is the grammar.md correct?

@juntyr juntyr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes, I left some further comments

Comment thread README.md Outdated
Comment thread docs/grammar.md Outdated
Comment thread docs/grammar.md
Comment thread docs/grammar.md Outdated
Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs
Comment thread src/de/mod.rs
Comment thread src/ser/mod.rs Outdated
Comment thread tests/601_support_for_number_ranges.rs
Comment thread tests/601_support_for_number_ranges.rs
@Ztry8

Ztry8 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Thank you! l've already started to working on this

Ztry8 and others added 7 commits April 28, 2026 04:18
Co-authored-by: Juniper Tyree <50025784+juntyr@users.noreply.github.com>
Co-authored-by: Juniper Tyree <50025784+juntyr@users.noreply.github.com>
Co-authored-by: Juniper Tyree <50025784+juntyr@users.noreply.github.com>
Co-authored-by: Juniper Tyree <50025784+juntyr@users.noreply.github.com>
@Ztry8

Ztry8 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, I’m happy with the work we’ve done, thank you very much!

I’ve implemented all of your suggestions & fixed CI.
Could you please check?

Comment thread src/de/mod.rs Outdated
Comment thread src/de/mod.rs Outdated
@Ztry8

Ztry8 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, thanks for the corrections, I didn't notice them
What do you think now?

@juntyr juntyr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're on the home stretch now - there's also a conversation from earlier on about moving the number deserialiser that I unresolved - please have a look at that as well

Comment thread tests/601_support_for_number_ranges.rs
Comment thread tests/601_support_for_number_ranges.rs
Comment thread tests/601_support_for_number_ranges.rs Outdated
@Ztry8

Ztry8 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! l've already started to working on this
Sorry about the number deserializer, I didn't understand what I needed to do at first

@Ztry8

Ztry8 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, many thanks!

I've improved the tests, added more clarification in the comments, and moved the number deserializer

Comment thread tests/601_support_for_number_ranges.rs
Comment thread src/value/mod.rs Outdated
@juntyr

juntyr commented Jun 4, 2026

Copy link
Copy Markdown
Member

@Ztry8 Thanks, we're almost almost there - thank you so much for making all these final adjustments

@Ztry8

Ztry8 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, thank you for your help and cooperation!
I'm glad I can help make RON better, and I'm really happy with the progress we've made!

What's left to do?

Comment thread tests/601_support_for_number_ranges.rs
Comment thread tests/601_support_for_number_ranges.rs Outdated
@Ztry8

Ztry8 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, what do you think now?

Comment thread tests/601_support_for_number_ranges.rs
@Ztry8

Ztry8 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, what do you think now?

@juntyr juntyr merged commit 6529e97 into ron-rs:master Jun 4, 2026
10 checks passed
@juntyr

juntyr commented Jun 4, 2026

Copy link
Copy Markdown
Member

@Ztry8 Thank you so much for your amazing work on this feature! I've now merged the PR.

Let's give the PR a few days on main to try it out, and then I'll release a new version with the feature (feel free to ping me if I forget).

@Ztry8

Ztry8 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@juntyr, thank you for your help and cooperation!
I'm glad I can help make RON better, and I'm really happy with the progress we've made!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants