Skip to content

Vec: looks like is_empty and len are not needed #26980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Vec: looks like is_empty and len are not needed #26980

wants to merge 1 commit into from

Conversation

tshepang
Copy link
Member

The slice module already implements these methods

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@tshepang
Copy link
Member Author

Does my change break anything? make check succeeds (on my Debian machine).

@Gankra
Copy link
Contributor

Gankra commented Jul 12, 2015

No this seems totally legit (although it probably forced the optimizer do a bit more work on these methods...).

@Gankra
Copy link
Contributor

Gankra commented Jul 12, 2015

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 12, 2015

📌 Commit 42b46d2 has been approved by Gankro

@petrochenkov
Copy link
Contributor

I will break code using Vec::len or Vec::is_empty as function objects:

fn main() {
    let vecs = vec![vec![1], vec![1, 2], vec![1, 2, 3]];
    for len in vecs.iter().map(Vec::len) { // <- No autoderef happens here, len is not found
        println!("{}", len);
    }
}

@Gankra
Copy link
Contributor

Gankra commented Jul 12, 2015

Woah! I didn't realize we had implemented that!

On Sat, Jul 11, 2015 at 6:47 PM, Vadim Petrochenkov <
notifications@github.com> wrote:

I will break code using Vec::len or Vec::is_empty as function objects:

fn main() {
let vecs = vec![vec![1], vec![1, 2], vec![1, 2, 3]];
for len in vecs.iter().map(Vec::len) { // <- No autoderef happens here, len is not found
println!("{}", len);
}
}


Reply to this email directly or view it on GitHub
#26980 (comment).

@Gankra
Copy link
Contributor

Gankra commented Jul 12, 2015

@bors r-

Want to think about this then

On Sat, Jul 11, 2015 at 7:00 PM, Alexis Beingessner <a.beingessner@gmail.com

wrote:

Woah! I didn't realize we had implemented that!

On Sat, Jul 11, 2015 at 6:47 PM, Vadim Petrochenkov <
notifications@github.com> wrote:

I will break code using Vec::len or Vec::is_empty as function objects:

fn main() {
let vecs = vec![vec![1], vec![1, 2], vec![1, 2, 3]];
for len in vecs.iter().map(Vec::len) { // <- No autoderef happens here, len is not found
println!("{}", len);
}
}


Reply to this email directly or view it on GitHub
#26980 (comment).

@reem
Copy link
Contributor

reem commented Jul 12, 2015

Seems we just cannot do this.

@tshepang
Copy link
Member Author

Does this mean the test suite is incomplete @petrochenkov?

@retep998
Copy link
Member

@tshepang The test suite is always incomplete. There are numerous ways to cause breaking changes in Rust without tripping the test suite. That's why PRs are manually reviewed and brson does crater runs on occasion to see if anything on crates.io broke.

@nagisa
Copy link
Member

nagisa commented Jul 12, 2015

You can’t just remove these methods without deprecating them either. I’d propose deprecation of these two functions as an RFC.

@Gankra
Copy link
Contributor

Gankra commented Jul 12, 2015

This super isn't worth it. They're two stupid little functions that have 0 maintenance burden.

Thanks anyway, @tshepang!

@Gankra Gankra closed this Jul 12, 2015
@tshepang tshepang deleted the is-this-needed branch July 13, 2015 08:10
@tshepang
Copy link
Member Author

@nagisa if they are deprecated, how would one use the non-deprecated ones? Won't the deprecated ones mask those that are not deprecated?

@gankro do you think these methods are just an oversight?

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.

9 participants