Skip to content

Commit 1567635

Browse files
authored
refactor!: rename builder methods for clarity and consistency (#1558)
1 parent f868658 commit 1567635

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.changes/builder-naming.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"wry": "minor:breaking"
3+
---
4+
5+
Rename `WebViewBuilder` methods for consistency and clarity:
6+
7+
- Renamed `WebViewBuilder::with_web_context` to `WebViewBuilder::new_with_web_context`
8+
- Renamed `WebViewBuilder::with_attributes` to `WebViewBuilder::new_with_attributes`

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl<'a> WebViewBuilder<'a> {
768768
}
769769

770770
/// Create a new [`WebViewBuilder`] with a web context that can be shared with multiple [`WebView`]s.
771-
pub fn with_web_context(web_context: &'a mut WebContext) -> Self {
771+
pub fn new_with_web_context(web_context: &'a mut WebContext) -> Self {
772772
let attrs = WebViewAttributes {
773773
context: Some(web_context),
774774
..Default::default()
@@ -783,7 +783,7 @@ impl<'a> WebViewBuilder<'a> {
783783
}
784784

785785
/// Create a new [`WebViewBuilder`] with the given [`WebViewAttributes`]
786-
pub fn with_attributes(attrs: WebViewAttributes<'a>) -> Self {
786+
pub fn new_with_attributes(attrs: WebViewAttributes<'a>) -> Self {
787787
Self {
788788
attrs,
789789
#[allow(clippy::default_constructed_unit_structs)]
@@ -1756,7 +1756,7 @@ impl WebView {
17561756
/// - Panics if the provided handle was not supported or invalid.
17571757
/// - Panics on Linux, if [`gtk::init`] was not called in this thread.
17581758
pub fn new(window: &impl HasWindowHandle, attrs: WebViewAttributes) -> Result<Self> {
1759-
WebViewBuilder::with_attributes(attrs).build(window)
1759+
WebViewBuilder::new_with_attributes(attrs).build(window)
17601760
}
17611761

17621762
/// Create [`WebViewBuilder`] as a child window inside the provided [`HasWindowHandle`].
@@ -1782,7 +1782,7 @@ impl WebView {
17821782
/// - Panics if the provided handle was not support or invalid.
17831783
/// - Panics on Linux, if [`gtk::init`] was not called in this thread.
17841784
pub fn new_as_child(parent: &impl HasWindowHandle, attrs: WebViewAttributes) -> Result<Self> {
1785-
WebViewBuilder::with_attributes(attrs).build_as_child(parent)
1785+
WebViewBuilder::new_with_attributes(attrs).build_as_child(parent)
17861786
}
17871787

17881788
/// Returns the id of this webview.

0 commit comments

Comments
 (0)