Skip to content

Conversation

abelardogit
Copy link

No description provided.

Comment on lines +33 to 35
if cfg!(target_os = MACOS) {
concat_for_accel = "<Meta>";
}
Copy link
Owner

Choose a reason for hiding this comment

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

This is not going to compile. In Rust, it is not legal to change the value of a variable after assignment, because variables are immutable.

It is possible to re-declare a variable using the let keyword again, but using let inside an if would not work either because then the new variable is scoped to the let, so it regains the old value at the end of the block.

Given that these are macros (function names that end with ! are macros), they will always be inlined during compilation, therefore always translated to a single line of code that is either one concat! or the other. Therefore, there is no actual performance gain.

Comment on lines -99 to +101
} else if cfg!(target_os = "macos") {
} else if cfg!(target_os = MACOS) {
Copy link
Owner

Choose a reason for hiding this comment

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

This is not going to compile either for similar reasons.

cfg! is a macro that is evaluated during compilation in order to choose whether to generate the binary code for the if branch or not. Therefore, it doesn't have access to the MACOS variable, because the variable only exists after the program is running, but the if has to be evaluated here during compilation, so the variable doesn't exist yet.

I get the intentions of trying to use common strings, but in this case, it doesn't work as it looks from the outside. Don't consider this string as code, but as data (imagine it like a type parameter in a JSON object).

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.

3 participants