-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
46: Add ability to gc builder cache r=CAD97 a=CAD97 Draft while blocked on rust-lang/hashbrown#163 Also likely useful along these lines: a preload function that takes an `ArcBorrow<'_, Node>` and preloads the cache with the node and any transitive children. `drain_filter` is annoying -- what's the polarity of the filter? -- so this definitely needs a test to make sure it's keeping the correct elements. Co-authored-by: CAD97 <[email protected]>
- Loading branch information
Showing
4 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use sorbus::*; | ||
|
||
#[test] | ||
fn works_properly() { | ||
let kind0 = Kind(0); | ||
let kind1 = Kind(1); | ||
let kind2 = Kind(2); | ||
let mut builder = green::TreeBuilder::new(); | ||
|
||
#[rustfmt::skip] | ||
let inner = builder | ||
.start_node(kind1) | ||
.token(kind0, "kind") | ||
.finish_node() | ||
.finish(); | ||
|
||
#[rustfmt::skip] | ||
let outer = builder | ||
.start_node(kind2) | ||
.add(inner.clone()) | ||
.finish_node() | ||
.finish(); | ||
|
||
assert_eq!(builder.builder().size(), 3); | ||
|
||
drop(outer); | ||
builder.builder().gc(); | ||
assert_eq!(builder.builder().size(), 2); | ||
|
||
drop(inner); | ||
builder.builder().gc(); | ||
assert_eq!(builder.builder().size(), 0); | ||
} |