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

include only one variant in compiled code #2438

Merged
merged 2 commits into from
Jan 29, 2024
Merged

Conversation

kziemianek
Copy link
Member

@kziemianek kziemianek commented Jan 29, 2024

After this change only one expression will be present in compiled code, also there will be no if statement anymore.

Previous version was failing in this case:

#[cfg(feature = "production")]
fn print_prod() {
	info!("Prod")
}

#[cfg(not(feature = "production"))]
fn print_dev() {
	info!("Dev")
}

if_production_or!(
	print_prod(),
	print_dev()
);
105 |         print_dev()
    |         ^^^^^^^^^ not found in this scope

@kziemianek kziemianek requested a review from a team January 29, 2024 17:34
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

Looks good!

@kziemianek kziemianek enabled auto-merge (squash) January 29, 2024 18:55
@Kailai-Wang Kailai-Wang merged commit 7e9b430 into dev Jan 29, 2024
3 checks passed
@Kailai-Wang Kailai-Wang deleted the if_production_or_rework branch January 29, 2024 18:56
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.

None yet

2 participants