refactor!: rename builder methods for clarity and consistency (#1558)

This commit is contained in:
Amr Bashir
2025-05-24 17:04:41 +03:00
committed by GitHub
parent f868658d6f
commit 1567635ba5
2 changed files with 12 additions and 4 deletions

View File

@@ -0,0 +1,8 @@
---
"wry": "minor:breaking"
---
Rename `WebViewBuilder` methods for consistency and clarity:
- Renamed `WebViewBuilder::with_web_context` to `WebViewBuilder::new_with_web_context`
- Renamed `WebViewBuilder::with_attributes` to `WebViewBuilder::new_with_attributes`

View File

@@ -768,7 +768,7 @@ impl<'a> WebViewBuilder<'a> {
}
/// Create a new [`WebViewBuilder`] with a web context that can be shared with multiple [`WebView`]s.
pub fn with_web_context(web_context: &'a mut WebContext) -> Self {
pub fn new_with_web_context(web_context: &'a mut WebContext) -> Self {
let attrs = WebViewAttributes {
context: Some(web_context),
..Default::default()
@@ -783,7 +783,7 @@ impl<'a> WebViewBuilder<'a> {
}
/// Create a new [`WebViewBuilder`] with the given [`WebViewAttributes`]
pub fn with_attributes(attrs: WebViewAttributes<'a>) -> Self {
pub fn new_with_attributes(attrs: WebViewAttributes<'a>) -> Self {
Self {
attrs,
#[allow(clippy::default_constructed_unit_structs)]
@@ -1756,7 +1756,7 @@ impl WebView {
/// - Panics if the provided handle was not supported or invalid.
/// - Panics on Linux, if [`gtk::init`] was not called in this thread.
pub fn new(window: &impl HasWindowHandle, attrs: WebViewAttributes) -> Result<Self> {
WebViewBuilder::with_attributes(attrs).build(window)
WebViewBuilder::new_with_attributes(attrs).build(window)
}
/// Create [`WebViewBuilder`] as a child window inside the provided [`HasWindowHandle`].
@@ -1782,7 +1782,7 @@ impl WebView {
/// - Panics if the provided handle was not support or invalid.
/// - Panics on Linux, if [`gtk::init`] was not called in this thread.
pub fn new_as_child(parent: &impl HasWindowHandle, attrs: WebViewAttributes) -> Result<Self> {
WebViewBuilder::with_attributes(attrs).build_as_child(parent)
WebViewBuilder::new_with_attributes(attrs).build_as_child(parent)
}
/// Returns the id of this webview.