Skip to content
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

Implement std::iter::FromIterator<char> for Box<str> #65163

Closed
Duddino opened this issue Oct 6, 2019 · 9 comments
Closed

Implement std::iter::FromIterator<char> for Box<str> #65163

Duddino opened this issue Oct 6, 2019 · 9 comments
Assignees
Labels
A-collections Area: std::collections. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Duddino
Copy link
Contributor

Duddino commented Oct 6, 2019

This would allow to construct a Box from an iterator, example: let string: Box<str> = (0..5).map(|_| '☺').collect();

This issue has been assigned to @Duddino via this comment.

@jonas-schievink
Copy link
Contributor

Did you mean FromIterator?

@Duddino
Copy link
Contributor Author

Duddino commented Oct 6, 2019

Yes thank you

@Duddino Duddino changed the title Implement std::iter::Iterator<Item=char> for Box<str> Implement std::iter::FromIterator<char> for Box<str> Oct 6, 2019
@bluss
Copy link
Member

bluss commented Oct 6, 2019

The workaround to use until then is (0..5).map(|_| '☺').collect::<String>().into_boxed_str() which will be equivalent to the eventual solution in behaviour and performance.

@jonas-schievink jonas-schievink added A-collections Area: std::collections. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 6, 2019
@Duddino
Copy link
Contributor Author

Duddino commented Oct 6, 2019

@rustbot claim

@rustbot rustbot self-assigned this Oct 6, 2019
@Duddino
Copy link
Contributor Author

Duddino commented Oct 6, 2019

I made the change, should I proceed with a PR? Sorry if it's a stupid question, but it's my first issue

@bluss
Copy link
Member

bluss commented Oct 6, 2019

@Duddino I think you can. The equivalent thing for Box<[T]> was in #55843 and the process should be similar.

If you are curious, bigger changes - not this one - in Rust might require an RFC -- see the contributing file.

@Duddino
Copy link
Contributor Author

Duddino commented Oct 6, 2019

@Blussi Thank you!

@bluss
Copy link
Member

bluss commented Oct 8, 2019

PR is #65168

andersk added a commit to andersk/rust that referenced this issue Mar 18, 2020
These are analogous to impl FromIterator<A> for Box<[A]> (rust-lang#55843).

Fixes rust-lang#65163.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@andersk
Copy link
Contributor

andersk commented Apr 3, 2020

Presumably @dtolnay’s rejection of #70094 also constitutes a rejection of this bug.

@dtolnay dtolnay closed this as completed Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: std::collections. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants