Skip to content

Commit

Permalink
Add Default implementation for WeakDom (#379)
Browse files Browse the repository at this point in the history
Title basically explains everything. Aside from the fact that it is good
practise, `Default` is required e.g. when using `#[serde(skip)]`
attribute.
  • Loading branch information
DervexDev authored Dec 17, 2023
1 parent 04f1855 commit 9898697
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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
* Implemented `Default` for `WeakDom`, useful when using Serde or creating an empty `WeakDom`

## 2.6.0 (2023-10-03)
* Added `WeakDom::clone_multiple_into_external` that allows cloning multiple subtrees all at once into a given `WeakDom`, useful for preserving `Ref` properties that point across cloned subtrees ([#364])
Expand Down
10 changes: 10 additions & 0 deletions rbx_dom_weak/src/dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ impl WeakDom {
}
}

impl Default for WeakDom {
fn default() -> WeakDom {
WeakDom {
instances: HashMap::new(),
root_ref: Ref::none(),
unique_ids: HashSet::new(),
}
}
}

#[derive(Debug, Default)]
struct CloneContext {
queue: VecDeque<(Ref, Ref)>,
Expand Down

0 comments on commit 9898697

Please sign in to comment.