From 72d583dee49387e35b0cb7bb5ec14da6e5eabd4d Mon Sep 17 00:00:00 2001 From: Dervex <78505208+DervexHero@users.noreply.github.com> Date: Tue, 5 Mar 2024 00:04:01 +0100 Subject: [PATCH] Add `InstanceBuilder::with_referent` constructing method (#400) --- .gitignore | 5 ++++- rbx_dom_weak/CHANGELOG.md | 1 + rbx_dom_weak/src/instance.rs | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 29209146..061d7111 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,7 @@ Cargo.lock # Editor-specific folders and files /.vscode -sourcemap.json \ No newline at end of file +sourcemap.json + +# macOS Finder files +.DS_Store diff --git a/rbx_dom_weak/CHANGELOG.md b/rbx_dom_weak/CHANGELOG.md index dca7fac1..14002690 100644 --- a/rbx_dom_weak/CHANGELOG.md +++ b/rbx_dom_weak/CHANGELOG.md @@ -1,6 +1,7 @@ # rbx_dom_weak Changelog ## Unreleased Changes +* Added `InstanceBuilder::with_referent` that allows building instance with predefined `Ref` ## 2.7.0 (2024-01-16) * Implemented `Default` for `WeakDom`, useful when using Serde or creating an empty `WeakDom` diff --git a/rbx_dom_weak/src/instance.rs b/rbx_dom_weak/src/instance.rs index c576717b..7871c3c8 100644 --- a/rbx_dom_weak/src/instance.rs +++ b/rbx_dom_weak/src/instance.rs @@ -72,6 +72,14 @@ impl InstanceBuilder { self.referent } + /// Change the referent of the `InstanceBuilder`. + pub fn with_referent>(self, referent: R) -> Self { + Self { + referent: referent.into(), + ..self + } + } + /// Change the name of the `InstanceBuilder`. pub fn with_name>(self, name: S) -> Self { Self {