Skip to content

Fuse impls expose use of specialization (default fn) #70796

@Centril

Description

@Centril
Contributor

Context: #70750 (comment)

We have some uses of default fn in src/libcore/adapters/fuse.rs which allow users to specialize those functions. Instead, these default fns should be moved into internal (private) traits so that the specialization isn't exposed.

This issue has been assigned to @rakshith-ravi via this comment.

Activity

added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Apr 5, 2020
rakshith-ravi

rakshith-ravi commented on Apr 6, 2020

@rakshith-ravi
Contributor

Supp. Can I take this up?

Oh also, the file is in src/libcore/iter/adapters/fuse.rs not src/libcore/adapters/fuse.rs. Had me confused for a while, but picked it up from context of the other PR, just saying.

cuviper

cuviper commented on Apr 6, 2020

@cuviper
Member
self-assigned this
on Apr 6, 2020
cuviper

cuviper commented on Apr 6, 2020

@cuviper
Member

I fear what the extra indirection will do to #70332, but I guess we'll just have to see...

rakshith-ravi

rakshith-ravi commented on Apr 6, 2020

@rakshith-ravi
Contributor

Alright. I'll go through that as well and suggest changes there, in case I can think of any.

Unlike my last PR, this time, I'd like to give this a shot without any mentoring. However, if I get stuck somewhere, I might request for help. Bear with me please.

Anyways, it's a little too late for me here (IST). Will get on it first thing tomorrow morning. Thanks

cuviper

cuviper commented on Apr 6, 2020

@cuviper
Member

It's also possible that could work out better if there's a way for Chain to directly reach the non-specialized version, rather than shimming its own Defuse to avoid FusedIterator effects.

rakshith-ravi

rakshith-ravi commented on Apr 7, 2020

@rakshith-ravi
Contributor

So if I understand the situation correctly, we need to have Iterator inherit from IteratorInternal or something like that, which allows for specialization and perform all our specialized work on that, while not exposing the default fns to anything outside the crate, yes?

This will also mean that Iterator will provide a blanket implementation that uses the IteratorInternal's implementation.

rakshith-ravi

rakshith-ravi commented on Apr 7, 2020

@rakshith-ravi
Contributor

It's also possible that could work out better if there's a way for Chain to directly reach the non-specialized version, rather than shimming its own Defuse to avoid FusedIterator effects.

I don't think I entirely understand what you're saying. Could you help me clarify that please?

cuviper

cuviper commented on Apr 7, 2020

@cuviper
Member

We definitely don't want to change the Iterator trait, if that's what you mean. I would look at Zip and its ZipImpl to see how that's privately specialized.

It's also possible that could work out better if there's a way for Chain to directly reach the non-specialized version, rather than shimming its own Defuse to avoid FusedIterator effects.

I don't think I entirely understand what you're saying. Could you help me clarify that please?

My thought was that we could make #70332 use some internal part of your work, e.g. FuseImpl, to bypass some of the nested calls. But now I'm also trying another Chain independent of Fuse in #70896 which I think is promising...

rakshith-ravi

rakshith-ravi commented on Apr 7, 2020

@rakshith-ravi
Contributor

Alrighty. Let me know if #70322 requires something specific so that I can implement it accordingly. Would be happy to dive deep into this.

rakshith-ravi

rakshith-ravi commented on Apr 7, 2020

@rakshith-ravi
Contributor

We definitely don't want to change the Iterator trait, if that's what you mean. I would look at Zip and its ZipImpl to see how that's privately specialized.

Yup, an implementation similar to ZipImpl is exactly what I meant. I'll get right on it then

added a commit that references this issue on Apr 17, 2020
d194587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-iteratorsArea: IteratorsC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @cuviper@Centril@rakshith-ravi@rustbot

    Issue actions

      `Fuse` impls expose use of specialization (`default fn`) · Issue #70796 · rust-lang/rust