-
-
Notifications
You must be signed in to change notification settings - Fork 49
Ready to define dir paths as constants. #198
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,17 @@ use gtk::prelude::ActionMapExtManual; | |
use crate::config::{APP_ID, BASE_ID, RESOURCE_PATH}; | ||
use crate::win::CarteroWindow; | ||
use crate::windows::SettingsDialog; | ||
|
||
static MACOS: &str = "macos"; | ||
#[macro_export] | ||
macro_rules! accelerator { | ||
($accel:expr) => { | ||
if cfg!(target_os = "macos") { | ||
concat!("<Meta>", $accel) | ||
} else { | ||
concat!("<Primary>", $accel) | ||
let concat_for_accel: String = "<Primary>"; | ||
|
||
if cfg!(target_os = MACOS) { | ||
concat_for_accel = "<Meta>"; | ||
} | ||
|
||
concat!(concat_for_accel, $accel) | ||
}; | ||
} | ||
|
||
|
@@ -96,7 +98,7 @@ mod imp { | |
if let Some(settings) = gtk::Settings::default() { | ||
settings.set_gtk_font_name(Some("Segoe UI 10")); | ||
} | ||
} else if cfg!(target_os = "macos") { | ||
} else if cfg!(target_os = MACOS) { | ||
Comment on lines
-99
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not going to compile either for similar reasons.
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 |
||
if let Some(settings) = gtk::Settings::default() { | ||
settings.set_gtk_font_name(Some(".AppleSystemUIFont 14.5")); | ||
} | ||
|
@@ -230,7 +232,7 @@ impl CarteroApplication { | |
|
||
self.add_action_entries([settings, about, quit]); | ||
|
||
if cfg!(target_os = "macos") { | ||
if cfg!(target_os = MACOS) { | ||
let links = vec![ | ||
("menubar.user-manual", "https://cartero.danirod.es/docs/"), | ||
( | ||
|
There was a problem hiding this comment.
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 anif
would not work either because then the new variable is scoped to thelet
, 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 oneconcat!
or the other. Therefore, there is no actual performance gain.