Skip to content

Commit

Permalink
Add InstanceBuilder::with_referent constructing method (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev authored Mar 4, 2024
1 parent 7bf637c commit 72d583d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ Cargo.lock

# Editor-specific folders and files
/.vscode
sourcemap.json
sourcemap.json

# macOS Finder files
.DS_Store
1 change: 1 addition & 0 deletions rbx_dom_weak/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
8 changes: 8 additions & 0 deletions rbx_dom_weak/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ impl InstanceBuilder {
self.referent
}

/// Change the referent of the `InstanceBuilder`.
pub fn with_referent<R: Into<Ref>>(self, referent: R) -> Self {
Self {
referent: referent.into(),
..self
}
}

/// Change the name of the `InstanceBuilder`.
pub fn with_name<S: Into<String>>(self, name: S) -> Self {
Self {
Expand Down

0 comments on commit 72d583d

Please sign in to comment.