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

Add const_fn!{} macro to make functions const without duplication. #144

Merged
merged 2 commits into from
Apr 11, 2020

Conversation

m-ou-se
Copy link
Contributor

@m-ou-se m-ou-se commented Apr 11, 2020

Many functions that can be const live in a generic context with bounds,
where const fn is not allowed without the "const_fn" feature.
In many places, functions duplicated becaue of this: A version with and
version without const.

This macro cleans that up by making it easy to define a function as
const only if possible, removing all duplication.

Also makes some more functions const.

m-ou-se added 2 commits April 11, 2020 11:04
Many functions that can be const live in a generic context with bounds,
where `const fn` is not allowed without the "const_fn" feature.
In many places, functions duplicated becaue of this: A version with and
version without `const`.

This macro cleans that up by making it easy to define a function as
const only if possible, removing all duplication.

Also makes some more functions const using this macro.
Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@phil-opp phil-opp merged commit 2442fd9 into rust-osdev:master Apr 11, 2020
@m-ou-se m-ou-se deleted the const_fn branch April 11, 2020 10:19
phil-opp added a commit that referenced this pull request Apr 11, 2020
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.

2 participants