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

Make str::ends_with a const fn #50899

Closed
alex opened this issue May 19, 2018 · 4 comments
Closed

Make str::ends_with a const fn #50899

alex opened this issue May 19, 2018 · 4 comments

Comments

@alex
Copy link
Member

alex commented May 19, 2018

Currently it can't be called from a const fn, which is sad :-(

Ordinarily I'd take a pass at implementing this myself, but str::ends_with is slightly more complex than meets the eye because of the Pattern abstraction, and I'm not particularly sure how that's best handled.

@oli-obk
Copy link
Contributor

oli-obk commented May 19, 2018

This is very hard! We need if at the least (which has a merged RFC). But we also need rust-lang/rfcs#2345 to abort in the case of bad indices.

I don't think this can be done any time soon and keeping an extra issue open for it is not really much use.

There's also a chance we need a new RFC entirely to be able to do this (due to the internal indexing traits being involved)

Once all the prerequisites are fulfilled we'll definitely do this though.

@oli-obk oli-obk closed this as completed May 19, 2018
@alex
Copy link
Member Author

alex commented May 19, 2018

👍 thanks for the quick response!

@FalkWoldmann
Copy link

Hi @oli-obk, I hope you don’t mind me bringing this up again. Since the linked PR has been merged and a couple of years have passed, do you think it would now be possible to implement this feature?

@oli-obk
Copy link
Contributor

oli-obk commented Dec 9, 2024

The groundwork for this is happening right now under the const_traits feature gate: #67792

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

No branches or pull requests

3 participants