New method on Range struct

In todays AdventOfCode i implemented my own extension Trait for Range and RangeInclusive and i wonder why Range doesnt have a new() method but RangeInclusive does.
At that opportunity i looked at the docs and RangeInclusivedoes have a few methods more than Range.
Now my question:

Is there a specific reason for that?

I tried to google it, but i found nothing.

Here the links to the docs:
Range: Range in std::ops - Rust
RangeInclusive: RangeInclusive in std::ops - Rust

Range has all public fields, so you can construct it without a dedicated method. The same goes for accessors/getters. You don't need Range::start() and Range::end() to be separate methods because you can just use the fields directly.

1 Like

oh okay that makes sense.
Thank you.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.