<!-- Thank you for creating a tracking issue! Tracking issues are for tracking a feature from implementation to stabilization. Make sure to include the relevant RFC for the feature if it has one. If the new feature is small, it may be fine to skip the RFC process. In that case, you can use `issue = "none"` in your initial implementation PR. The reviewer will ask you to open a tracking issue if they agree your feature can be added without an RFC. --> Feature gate: `#![feature(range_bounds_is_empty)]` This is a tracking issue for the `is_empty` method on `RangeBounds`. <!-- Include a short description of the feature. --> ### Public API <!-- For most library features, it'd be useful to include a summarized version of the public API. (E.g. just the public function signatures without their doc comments or implementation.) --> ```rust // core::ops pub trait RangeBounds<T: ?Sized> { ... fn is_empty(&self) -> bool where T: PartialOrd, { ... } } ``` ### Steps / History <!-- For larger features, more steps might be involved. If the feature is changed later, please add those PRs here as well. --> - ACP: https://github.com/rust-lang/libs-team/issues/539 - [x] Implementation: #137304 - [ ] Final comment period (FCP)[^1] - [ ] Stabilization PR <!-- Once the feature has gone through a few release cycles and there are no unresolved questions left, the feature might be ready for stabilization. If this feature didn't go through the RFC process, a final comment period (FCP) is always needed before stabilization. This works as follows: A library API team member can kick off the stabilization process, at which point the rfcbot will ask all the team members to verify they agree with stabilization. Once enough members agree and there are no concerns, the final comment period begins: this issue will be marked as such and will be listed in the next This Week in Rust newsletter. If no blocking concerns are raised in that period of 10 days, a stabilization PR can be opened by anyone. --> ### Unresolved Questions <!-- Include any open questions that need to be answered before the feature can be stabilised. If multiple (unrelated) big questions come up, it can be a good idea to open a separate issue for each, to make it easier to keep track of the discussions. It's useful to link any relevant discussions and conclusions (whether on GitHub, Zulip, or the internals forum) here. --> - `(Excluded(1), Excluded(2))` is considered to be non-empty. This could be a foot gun. Should we add a trait bound to avoid it? Related issues: - https://github.com/rust-lang/rust/issues/149625 - https://github.com/rust-lang/libs-team/issues/277#issuecomment-3036913432 - https://github.com/rust-lang/libs-team/issues/539 [^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html
Activity
Rollup merge of rust-lang#137304 - pitaj:rangebounds-is_empty-interse…
Rollup merge of rust-lang#137304 - pitaj:rangebounds-is_empty-interse…
scottmcm commentedon Feb 27, 2025
This feels like it really wants
#[final]so that unsafe code can actually use it.Rollup merge of rust-lang#137304 - pitaj:rangebounds-is_empty-interse…
pitaj commentedon Feb 27, 2025
Does
#[final]allow types in the same crate to still specialize? Would be kinda a shame if the infinite range types couldn't just returntrue.Unrolled build for rust-lang#137304
Rollup merge of rust-lang#137304 - pitaj:rangebounds-is_empty-interse…
Rollup merge of rust-lang#137304 - pitaj:rangebounds-is_empty-interse…
judnich commentedon Jul 4, 2025
Link to comment/discussion: There is a serious correctness bug in the current API design.