Skip to content
New issue

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

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

Already on GitHub? # to your account

Tracking Issue for ControlFlow::into_value #137461

Open
2 of 4 tasks
scottmcm opened this issue Feb 23, 2025 · 10 comments
Open
2 of 4 tasks

Tracking Issue for ControlFlow::into_value #137461

scottmcm opened this issue Feb 23, 2025 · 10 comments
Assignees
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented Feb 23, 2025

Feature gate: #![feature(control_flow_into_value)]

This is a tracking issue for the into_value method on ControlFlow<T, T>: https://doc.rust-lang.org/nightly/std/ops/enum.ControlFlow.html#method.into_value

Public API

// core::ops

impl<T> ControlFlow<T, T> {
    // hopefully const one day, but that needs `~const Destruct`
    // or precise drop calculations
    pub fn into_value(self) -> T;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@scottmcm scottmcm added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Feb 23, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Feb 23, 2025

This has an approved ACP (cc @carbotaniuman), but wasn't implemented. Anyone interested? Adding one unstable function is one of the easiest ways to have a first PR!

@scottmcm scottmcm changed the title Tracking Issue for XXX Tracking Issue for ControlFlow::into_value Feb 23, 2025
@chenyukang
Copy link
Member

@randyli
may be interested in taking it.

@madhav-madhusoodanan
Copy link
Contributor

madhav-madhusoodanan commented Feb 23, 2025

Hi @scottmcm
I've been studying the rust compiler and I'd love to put in effort towards this.

How should I approach this?

@Shourya742
Copy link
Contributor

@rustbot claim

@madhav-madhusoodanan
Copy link
Contributor

@Shourya742 hi, as you can see I was interested in working on this issue.

Would it be alright if I claim this?

@Shourya742
Copy link
Contributor

Shourya742 commented Feb 23, 2025

@Shourya742 hi, as you can see I was interested in working on this issue.

Would it be alright if I claim this?

My bad .. I didn't read through the comment... You can claim it...
@rustbot release-assignment

@chenyukang
Copy link
Member

chenyukang commented Feb 23, 2025

@madhav-madhusoodanan
Great, you should add a new api for ControlFlow, probably here:

https://github.com/chenyukang/rust/blob/1a440d56d63458e4491f289c4950396f73304264/library/core/src/ops/control_flow.rs#L136

Don't forget the feature gate control_flow_into_value.

And read more details in rust-lang/libs-team#474 (comment) and https://std-dev-guide.rust-lang.org/

@madhav-madhusoodanan
Copy link
Contributor

madhav-madhusoodanan commented Feb 23, 2025

Got it, going through it now

@madhav-madhusoodanan
Copy link
Contributor

madhav-madhusoodanan commented Feb 23, 2025

Public API

// core::ops

impl ControlFlow<T, T> {
pub const fn into_value(self) -> T;
}

Just to clarify, is the public API supposed to be a const fn?
I was facing an issue with Destructor cannot be evaluated at compile-time with the const fn version

@madhav-madhusoodanan
Copy link
Contributor

Nevermind, I was able to implement it as a const fn using the #[rustc_allow_const_fn_unstable(const_precise_live_drops)] feature.

@scottmcm scottmcm removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Mar 11, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants