Browse Source

`App.create_window()` to accept any `Into<String>` type (fix #2290) (#2291)

* Fix `App.create_window()` to accept any `Into<String>` type

* Update changefile to show both changed functions

* Reduce changefile level to patch

Co-authored-by: Wouter Buckens <wouter@epicteddy.com>
chip 4 years ago
parent
commit
8216cba13d
3 changed files with 12 additions and 2 deletions
  1. 5 0
      .changes/fix-create-window-str.md
  2. 6 1
      core/tauri/src/app.rs
  3. 1 1
      examples/api/src-tauri/src/main.rs

+ 5 - 0
.changes/fix-create-window-str.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Change `App.create_window()` and `AppHandle.create_window()` to accept an `Into<String>` type instead of `String`.

+ 6 - 1
core/tauri/src/app.rs

@@ -225,7 +225,12 @@ macro_rules! shared_app_impl {
   ($app: ty) => {
     impl<R: Runtime> $app {
       /// Creates a new webview window.
-      pub fn create_window<F>(&self, label: String, url: WindowUrl, setup: F) -> crate::Result<()>
+      pub fn create_window<F>(
+        &self,
+        label: impl Into<String>,
+        url: WindowUrl,
+        setup: F,
+      ) -> crate::Result<()>
       where
         F: FnOnce(
           <R::Dispatcher as Dispatch>::WindowBuilder,

+ 1 - 1
examples/api/src-tauri/src/main.rs

@@ -82,7 +82,7 @@ fn main() {
           }
           "new" => app
             .create_window(
-              "new".into(),
+              "new",
               WindowUrl::App("index.html".into()),
               |window_builder, webview_attributes| {
                 (window_builder.title("Tauri"), webview_attributes)