Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for Range[Inclusive]::is_empty (feature range_is_empty) #48111
Comments
scottmcm
added a commit
to scottmcm/rust
that referenced
this issue
Feb 10, 2018
pietroalbini
added
T-libs
C-tracking-issue
labels
Feb 10, 2018
scottmcm
referenced this issue
Feb 20, 2018
Open
Add `is_empty` function to `ExactSizeIterator` #35428
This comment has been minimized.
This comment has been minimized.
|
This method is really hard to use. In the program:
Rust 1.31 in the playground (which is 2018 Edition) complains:
This arises without any imports in scope, just the prelude. Using
does work, but is longer than |
This comment has been minimized.
This comment has been minimized.
|
@jimblandy The ambiguity happens only because you haven't enabled the relevant features. Assuming both #![feature(exact_size_is_empty, range_is_empty)]
use std::iter::ExactSizeIterator;
fn main() {
println!("{:?}", (0..0).is_empty());
} |
This comment has been minimized.
This comment has been minimized.
|
I believe that's an artifact of both being unstable, @jimblandy. With either or both feature gates enabled, it compiles fine (with a future warning if only the ESI gate is active): #![feature(range_is_empty)]
#![feature(exact_size_is_empty)]
fn main() {
println!("{:?}", (0..0).is_empty());
}Edit: doh, 20 seconds late |
This comment has been minimized.
This comment has been minimized.
|
Okay, thanks for the explanation. I guess I'm still surprised that the error message is about the ambiguity, not the use of unstable features; is it that rustc can't decide which unstable feature's use to complain about? ^^;; |
scottmcm commentedFeb 10, 2018
•
edited
These methods are a clear way to check for empty ranges without the restrictions of
ExactSizeIterator.Merged 2018-02-15 in PR at #48087