From 26bc7a4c92431a8f1047354e60ca8066c7eaf58f Mon Sep 17 00:00:00 2001 From: sawyer bristol Date: Thu, 3 Oct 2024 14:01:02 -0600 Subject: [PATCH] bookmarks as slice --- examples/basic_browser.rs | 5 +---- examples/keyboard_driven.rs | 2 +- src/lib.rs | 1 + src/widgets/mod.rs | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/basic_browser.rs b/examples/basic_browser.rs index c4cc16e..beae140 100644 --- a/examples/basic_browser.rs +++ b/examples/basic_browser.rs @@ -8,10 +8,7 @@ fn run() -> (BasicBrowser, Task) { BasicBrowser::new_basic() .with_tab_bar() .with_nav_bar() - .with_bookmark_bar(vec![Bookmark::new( - "https://www.rust-lang.org", - "rust-lang.org", - )]) + .with_bookmark_bar(&[Bookmark::new("https://www.rust-lang.org", "rust-lang.org")]) .build(), Task::none(), ) diff --git a/examples/keyboard_driven.rs b/examples/keyboard_driven.rs index 9474bf8..67f80aa 100644 --- a/examples/keyboard_driven.rs +++ b/examples/keyboard_driven.rs @@ -50,7 +50,7 @@ impl Default for Browser { let widgets = BrowserWidget::new_basic() .with_custom_shortcuts(shortcuts) .with_tab_bar() - .with_bookmark_bar(vec![ + .with_bookmark_bar(&[ Bookmark::new("https://www.rust-lang.org", "rust-lang.org"), Bookmark::new( "https://github.com/LegitCamper/icy_browser", diff --git a/src/lib.rs b/src/lib.rs index e859a63..93144da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,7 @@ fn to_url(url: &str) -> Option { } } +#[derive(Debug, Clone)] pub struct Bookmark { url: Url, name: String, diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs index a09b6b2..17d4c48 100644 --- a/src/widgets/mod.rs +++ b/src/widgets/mod.rs @@ -172,8 +172,8 @@ where self } - pub fn with_bookmark_bar(mut self, bookmarks: Vec) -> Self { - self.bookmarks = Some(bookmarks); + pub fn with_bookmark_bar(mut self, bookmarks: &[Bookmark]) -> Self { + self.bookmarks = Some(bookmarks.to_vec()); self }