Skip to content

Commit

Permalink
fix(core): apply clippy suggestions (#10394)
Browse files Browse the repository at this point in the history
* fix(core): apply clippy suggestions

* more fixes
  • Loading branch information
lucasfernog authored Jul 29, 2024
1 parent e177694 commit efdce03
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 64 deletions.
12 changes: 7 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/tauri-runtime/src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl WebviewAttributes {
///
/// - **Windows**: Controls WebView2's [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting.
/// - **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`,
/// 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission
/// 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission
///
/// - **Android / iOS**: Unsupported.
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion core/tauri-runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ pub trait WindowBuilder: WindowBuilderBase {
/// - **Windows:**
/// - `false` has no effect on decorated window, shadows are always ON.
/// - `true` will make ndecorated window have a 1px white border,
/// and on Windows 11, it will have a rounded corners.
/// and on Windows 11, it will have a rounded corners.
/// - **Linux:** Unsupported.
#[must_use]
fn shadow(self, enable: bool) -> Self;
Expand Down
16 changes: 8 additions & 8 deletions core/tauri-utils/src/config/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub fn is_configuration_file(target: Target, path: &Path) -> bool {
/// - `tauri.windows.conf.json[5]` or `Tauri.windows.toml` on Windows
/// - `tauri.android.conf.json[5]` or `Tauri.android.toml` on Android
/// - `tauri.ios.conf.json[5]` or `Tauri.ios.toml` on iOS
/// Merging the configurations using [JSON Merge Patch (RFC 7396)].
/// Merging the configurations using [JSON Merge Patch (RFC 7396)].
///
/// [JSON Merge Patch (RFC 7396)]: https://datatracker.ietf.org/doc/html/rfc7396.
pub fn read_from(target: Target, root_dir: PathBuf) -> Result<Value, ConfigError> {
Expand Down Expand Up @@ -224,15 +224,15 @@ pub fn does_supported_file_name_exist(target: Target, path: impl Into<PathBuf>)
///
/// Hierarchy:
/// 1. Check if `tauri.conf.json` exists
/// a. Parse it with `serde_json`
/// b. Parse it with `json5` if `serde_json` fails
/// c. Return original `serde_json` error if all above steps failed
/// a. Parse it with `serde_json`
/// b. Parse it with `json5` if `serde_json` fails
/// c. Return original `serde_json` error if all above steps failed
/// 2. Check if `tauri.conf.json5` exists
/// a. Parse it with `json5`
/// b. Return error if all above steps failed
/// a. Parse it with `json5`
/// b. Return error if all above steps failed
/// 3. Check if `Tauri.json` exists
/// a. Parse it with `toml`
/// b. Return error if all above steps failed
/// a. Parse it with `toml`
/// b. Return error if all above steps failed
/// 4. Return error if all above steps failed
pub fn parse(target: Target, path: impl Into<PathBuf>) -> Result<(Config, PathBuf), ConfigError> {
do_parse(target, path.into())
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! - **isolation**: Enables the isolation pattern. Enabled by default if the `app > security > pattern > use` config option is set to `isolation` on the `tauri.conf.json` file.
//! - **custom-protocol**: Feature managed by the Tauri CLI. When enabled, Tauri assumes a production environment instead of a development one.
//! - **devtools**: Enables the developer tools (Web inspector) and [`window::Window#method.open_devtools`]. Enabled by default on debug builds.
//! On macOS it uses private APIs, so you can't enable it if your app will be published to the App Store.
//! On macOS it uses private APIs, so you can't enable it if your app will be published to the App Store.
//! - **native-tls**: Provides TLS support to connect over HTTPS.
//! - **native-tls-vendored**: Compile and statically link to a vendored copy of OpenSSL.
//! - **rustls-tls**: Provides TLS support to connect over HTTPS using rustls.
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/builders/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl CheckMenuItemBuilder {
/// Create a new menu item builder.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<S: AsRef<str>>(text: S) -> Self {
Self {
id: None,
Expand All @@ -31,7 +31,7 @@ impl CheckMenuItemBuilder {
/// Create a new menu item builder with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<I: Into<MenuId>, S: AsRef<str>>(id: I, text: S) -> Self {
Self {
id: Some(id.into()),
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/builders/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> IconMenuItemBuilder<'a> {
/// Create a new menu item builder.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<S: AsRef<str>>(text: S) -> Self {
Self {
id: None,
Expand All @@ -37,7 +37,7 @@ impl<'a> IconMenuItemBuilder<'a> {
/// Create a new menu item builder with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<I: Into<MenuId>, S: AsRef<str>>(id: I, text: S) -> Self {
Self {
id: Some(id.into()),
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/builders/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl MenuItemBuilder {
/// Create a new menu item builder.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<S: AsRef<str>>(text: S) -> Self {
Self {
id: None,
Expand All @@ -29,7 +29,7 @@ impl MenuItemBuilder {
/// Create a new menu item builder with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<I: Into<MenuId>, S: AsRef<str>>(id: I, text: S) -> Self {
Self {
id: Some(id.into()),
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/builders/submenu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'m, R: Runtime, M: Manager<R>> SubmenuBuilder<'m, R, M> {
/// Create a new submenu builder.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<S: AsRef<str>>(manager: &'m M, text: S) -> Self {
Self {
id: None,
Expand All @@ -62,7 +62,7 @@ impl<'m, R: Runtime, M: Manager<R>> SubmenuBuilder<'m, R, M> {
/// Create a new submenu builder with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<I: Into<MenuId>, S: AsRef<str>>(manager: &'m M, id: I, text: S) -> Self {
Self {
id: Some(id.into()),
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<R: Runtime> CheckMenuItem<R> {
/// Create a new menu item.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<M, T, A>(
manager: &M,
text: T,
Expand Down Expand Up @@ -49,7 +49,7 @@ impl<R: Runtime> CheckMenuItem<R> {
/// Create a new menu item with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<M, I, T, A>(
manager: &M,
id: I,
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<R: Runtime> IconMenuItem<R> {
/// Create a new menu item.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<M, T, A>(
manager: &M,
text: T,
Expand Down Expand Up @@ -52,7 +52,7 @@ impl<R: Runtime> IconMenuItem<R> {
/// Create a new menu item with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<M, I, T, A>(
manager: &M,
id: I,
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/menu/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<R: Runtime> MenuItem<R> {
/// Create a new menu item.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn new<M, T, A>(
manager: &M,
text: T,
Expand Down Expand Up @@ -48,7 +48,7 @@ impl<R: Runtime> MenuItem<R> {
/// Create a new menu item with the specified id.
///
/// - `text` could optionally contain an `&` before a character to assign this character as the mnemonic
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
/// for this menu item. To display a `&` without assigning a mnemenonic, use `&&`.
pub fn with_id<M, I, T, A>(
manager: &M,
id: I,
Expand Down
24 changes: 12 additions & 12 deletions core/tauri/src/tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl From<tray_icon::MouseButton> for MouseButton {
/// ## Platform-specific:
///
/// - **Linux**: Unsupported. The event is not emmited even though the icon is shown
/// and will still show a context menu on right click.
/// and will still show a context menu on right click.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<R: Runtime> TrayIconBuilder<R> {
/// ## Platform-specific:
///
/// - **Linux:** Sometimes the icon won't be visible unless a menu is set.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
pub fn new() -> Self {
Self {
inner: tray_icon::TrayIconBuilder::new(),
Expand All @@ -208,7 +208,7 @@ impl<R: Runtime> TrayIconBuilder<R> {
/// ## Platform-specific:
///
/// - **Linux:** Sometimes the icon won't be visible unless a menu is set.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
pub fn with_id<I: Into<TrayIconId>>(id: I) -> Self {
let mut builder = Self::new();
builder.inner = builder.inner.with_id(id);
Expand All @@ -230,7 +230,7 @@ impl<R: Runtime> TrayIconBuilder<R> {
/// ## Platform-specific:
///
/// - **Linux:** Sometimes the icon won't be visible unless a menu is set.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
pub fn icon(mut self, icon: Image<'_>) -> Self {
let icon = icon.try_into().ok();
if let Some(icon) = icon {
Expand All @@ -254,10 +254,10 @@ impl<R: Runtime> TrayIconBuilder<R> {
/// ## Platform-specific
///
/// - **Linux:** The title will not be shown unless there is an icon
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// - **Windows:** Unsupported.
pub fn title<S: AsRef<str>>(mut self, title: S) -> Self {
self.inner = self.inner.with_title(title);
Expand Down Expand Up @@ -471,10 +471,10 @@ impl<R: Runtime> TrayIcon<R> {
/// ## Platform-specific:
///
/// - **Linux:** The title will not be shown unless there is an icon
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// - **Windows:** Unsupported
pub fn set_title<S: AsRef<str>>(&self, title: Option<S>) -> crate::Result<()> {
let s = title.map(|s| s.as_ref().to_string());
Expand Down
10 changes: 5 additions & 5 deletions core/tauri/src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub enum DownloadEvent<'a> {
/// ## Platform-specific:
///
/// - **macOS**: The second parameter indicating the path the file was saved to is always empty, due to API
/// limitations.
/// limitations.
path: Option<PathBuf>,
/// Indicates if the download succeeded or not.
success: bool,
Expand Down Expand Up @@ -785,7 +785,7 @@ fn main() {
///
/// - **Windows**: Controls WebView2's [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting.
/// - **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`,
/// 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission
/// 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission
///
/// - **Android / iOS**: Unsupported.
#[must_use]
Expand Down Expand Up @@ -1367,7 +1367,7 @@ fn main() {
/// ## Platform-specific
///
/// - **macOS:** Only supported on macOS 10.15+.
/// This is a private API on macOS, so you cannot use this if your application will be published on the App Store.
/// This is a private API on macOS, so you cannot use this if your application will be published on the App Store.
///
/// # Examples
///
Expand Down Expand Up @@ -1397,7 +1397,7 @@ tauri::Builder::default()
/// ## Platform-specific
///
/// - **macOS:** Only supported on macOS 10.15+.
/// This is a private API on macOS, so you cannot use this if your application will be published on the App Store.
/// This is a private API on macOS, so you cannot use this if your application will be published on the App Store.
/// - **Windows:** Unsupported.
///
/// # Examples
Expand Down Expand Up @@ -1435,7 +1435,7 @@ tauri::Builder::default()
/// ## Platform-specific
///
/// - **macOS:** Only supported on macOS 10.15+.
/// This is a private API on macOS, so you cannot use this if your application will be published on the App Store.
/// This is a private API on macOS, so you cannot use this if your application will be published on the App Store.
/// - **Windows:** Unsupported.
///
/// # Examples
Expand Down
Loading

0 comments on commit efdce03

Please sign in to comment.