Skip to content

Commit aaecb6a

Browse files
refactor: rename tauri::dev to is_dev and mark as constant fn (#9890)
* refactor: made `tauri::dev` as constant function this enables the `tauri::dev()` can be used as const or static * is_dev && change files --------- Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
1 parent 27fd8cc commit aaecb6a

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

.changes/tauri-build-dev-fn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-build": "patch:breaking"
3+
---
4+
5+
Renamed `dev` function to `is_dev`

.changes/tauri-dev-fn-const.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": "patch:breaking"
3+
---
4+
5+
Renamed `dev` function to `is_dev` and marked it as `const fn`

core/tauri-build/src/codegen/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl CodegenContext {
121121
);
122122

123123
let code = context_codegen(ContextData {
124-
dev: crate::dev(),
124+
dev: crate::is_dev(),
125125
config,
126126
config_parent,
127127
// it's very hard to have a build script for unit tests, so assume this is always called from

core/tauri-build/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl Attributes {
386386
}
387387
}
388388

389-
pub fn dev() -> bool {
389+
pub fn is_dev() -> bool {
390390
std::env::var("DEP_TAURI_DEV")
391391
.expect("missing `cargo:dev` instruction, please update tauri to latest")
392392
== "true"
@@ -474,7 +474,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
474474
mobile::generate_gradle_files(project_dir, &config)?;
475475
}
476476

477-
cfg_alias("dev", dev());
477+
cfg_alias("dev", is_dev());
478478

479479
let ws_path = get_workspace_dir()?;
480480
let mut manifest =

core/tauri/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ macro_rules! tauri_build_context {
335335
pub use pattern::Pattern;
336336

337337
/// Whether we are running in development mode or not.
338-
pub fn dev() -> bool {
338+
pub const fn is_dev() -> bool {
339339
!cfg!(feature = "custom-protocol")
340340
}
341341

core/tauri/src/manager/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<R: Runtime> AppManager<R> {
330330
}
331331

332332
fn csp(&self) -> Option<Csp> {
333-
if !crate::dev() {
333+
if !crate::is_dev() {
334334
self.config.app.security.csp.clone()
335335
} else {
336336
self

0 commit comments

Comments
 (0)