From 4ad6b7b911eded3c58b26e9df51a70f442f80042 Mon Sep 17 00:00:00 2001 From: Bamidev Date: Fri, 1 Mar 2024 15:29:45 +0100 Subject: [PATCH] cargo +nightly fmt --- build.rs | 10 +++++++--- c/build.rs | 27 +++++++++++++++------------ c/src/lib.rs | 2 +- src/application.rs | 16 ++++++++++------ src/core/application.rs | 1 - src/core/application/c.rs | 2 +- src/tests.rs | 1 - 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/build.rs b/build.rs index d1b03d7..b514f61 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,14 @@ use std::env; - fn main() { - if env::var("DOCS_RS").is_err() && !cfg!(feature = "cef") && !cfg!(feature = "webkitgtk") && !cfg!(feature = "edge") { + if env::var("DOCS_RS").is_err() + && !cfg!(feature = "cef") + && !cfg!(feature = "webkitgtk") + && !cfg!(feature = "edge") + { panic!( - "No browser framework has been specified. Enable either feature `webkitgtk`, `cef` or `edge`." + "No browser framework has been specified. Enable either feature `webkitgtk`, `cef` or \ + `edge`." ); } } diff --git a/c/build.rs b/c/build.rs index 16fd3ed..d936bd4 100644 --- a/c/build.rs +++ b/c/build.rs @@ -13,14 +13,15 @@ use std::{ #[derive(Debug)] struct BwBindgenCallbacks {} - fn nuget_package_dir(package_name: &str) -> Option { let nuget_path = match env::var("USERPROFILE") { Err(e) => match env::var("NUGET_PATH") { Ok(string) => PathBuf::from(string), - Err(e) => panic!("Couldn't find the Nuget path, please set environment variable NUGET_PATH.") + Err(e) => { + panic!("Couldn't find the Nuget path, please set environment variable NUGET_PATH.") + } }, - Ok(string) => PathBuf::from(format!("{}\\.nuget\\packages\\", string)) + Ok(string) => PathBuf::from(format!("{}\\.nuget\\packages\\", string)), }; #[cfg(windows)] @@ -173,7 +174,7 @@ fn main() { /************************************** * C header files for bindgen - ******************************* */ + ****************************** */ let mut bgbuilder = bindgen::Builder::default() .parse_callbacks(Box::new(BwBindgenCallbacks {})) .clang_arg("-DBW_BINDGEN") @@ -187,7 +188,7 @@ fn main() { /************************************** * The Platform source files - ******************************* */ + ****************************** */ if target.contains("windows") { bgbuilder = bgbuilder.clang_arg("-DBW_WIN32"); if target.contains("msvc") { @@ -249,7 +250,7 @@ fn main() { /************************************** * The Browser Engine (CEF3) source files - ******************************* */ + ****************************** */ if cfg!(feature = "cef") { bgbuilder = bgbuilder.clang_arg("-DBW_CEF"); @@ -371,9 +372,10 @@ fn main() { } /**************************************** * Microsoft Edge WebView2 source files - ****************************************/ + ************************************** */ else if cfg!(feature = "edge") { - let webview_dir = nuget_package_dir("Microsoft.Web.WebView2").expect("Couldn't find Microsoft.Web.WebView2 Nuget package."); + let webview_dir = nuget_package_dir("Microsoft.Web.WebView2") + .expect("Couldn't find Microsoft.Web.WebView2 Nuget package."); let include_dir = webview_dir.join(PathBuf::from("build/native/include")); let lib_dir = if cfg!(target_arch = "x86") { webview_dir.join(PathBuf::from("build/native/x86")) @@ -393,13 +395,14 @@ fn main() { println!("cargo:rustc-link-lib=dylib=WebView2Loader"); } - bgbuilder = bgbuilder - .clang_arg("-DBW_EDGE"); + bgbuilder = bgbuilder.clang_arg("-DBW_EDGE"); // Add the MinGW header files and libraries when available if Path::new("/usr/share/mingw-w64/include/").exists() { build.include("/usr/share/mingw-w64/include/"); - build.include(PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap() + "/win32/include")); + build.include(PathBuf::from( + env::var("CARGO_MANIFEST_DIR").unwrap() + "/win32/include", + )); } build @@ -413,7 +416,7 @@ fn main() { /************************************** * All other source files - ******************************* */ + ****************************** */ build .file("src/application/common.c") .file("src/browser_window/common.c") diff --git a/c/src/lib.rs b/c/src/lib.rs index 83500c7..3fdd88a 100644 --- a/c/src/lib.rs +++ b/c/src/lib.rs @@ -6,7 +6,7 @@ pub use crate::bindings::*; /************************************************************** * Implementations for C structs that are also useful in Rust * - ******************************************************* */ + ****************************************************** */ impl cbw_CStrSlice { pub fn empty() -> Self { diff --git a/src/application.rs b/src/application.rs index fc11222..cc3e9f2 100644 --- a/src/application.rs +++ b/src/application.rs @@ -135,11 +135,13 @@ struct ApplicationDispatchSendData<'a> { #[derive(Default)] pub struct ApplicationSettings { - /// CEF only: If set, the path of the seperate executable that gets compiled together with your - /// main executable. If not set, no seperate executable will be used. + /// CEF only: If set, the path of the seperate executable that gets compiled + /// together with your main executable. If not set, no seperate executable + /// will be used. pub engine_seperate_executable_path: Option, - /// If set, this path will be where the browser framework will look for resources/assets. - /// If not set, it will default to the directory where the executable is located. + /// If set, this path will be where the browser framework will look for + /// resources/assets. If not set, it will default to the directory where the + /// executable is located. pub resource_dir: Option, /// CEF only: If set, will enable remote debugging at this port. pub remote_debugging_port: Option, @@ -238,13 +240,15 @@ impl Drop for Application { } impl ApplicationSettings { - pub fn default_resource_path() -> PathBuf { let mut path = env::current_exe().unwrap(); path.pop(); #[cfg(debug_assertions)] - { path.pop(); path.pop(); } + { + path.pop(); + path.pop(); + } path.push("resources"); diff --git a/src/core/application.rs b/src/core/application.rs index 6dcb89f..c57f546 100644 --- a/src/core/application.rs +++ b/src/core/application.rs @@ -15,7 +15,6 @@ pub use gtk::ApplicationImpl; use crate::{application::ApplicationSettings, error::Result}; - pub trait ApplicationExt: Clone { /// Asserts if not on the GUI thread fn assert_correct_thread(&self); diff --git a/src/core/application/c.rs b/src/core/application/c.rs index d26d57b..410f1cf 100644 --- a/src/core/application/c.rs +++ b/src/core/application/c.rs @@ -78,7 +78,7 @@ impl ApplicationExt for ApplicationImpl { .to_string_lossy() .as_ref() .into(), - remote_debugging_port: settings.remote_debugging_port.unwrap_or(0) + remote_debugging_port: settings.remote_debugging_port.unwrap_or(0), }; let mut c_handle: *mut cbw_Application = ptr::null_mut(); diff --git a/src/tests.rs b/src/tests.rs index ccb845f..473d425 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -109,7 +109,6 @@ async fn async_cookies(app: ApplicationHandle) { #[test] /// Checking if all cookie methods work correctly. fn cookie() { - if !cfg!(feature = "webkitgtk") { let now = SystemTime::now();