Skip to content

Commit

Permalink
buck2: tsets: expose children
Browse files Browse the repository at this point in the history
Summary: TSIA.

Reviewed By: cjhopman

Differential Revision: D62312933

fbshipit-source-id: 9affe99c6379d476e45c123dcd3a8a4b95f94bef
  • Loading branch information
navidqar authored and facebook-github-bot committed Sep 6, 2024
1 parent 9069798 commit b15f709
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,8 @@ fn transitive_set_methods(builder: &mut MethodsBuilder) {
None => Value::new_none(),
})
}
#[starlark(attribute)]
fn children<'v>(this: ValueOf<'v, &'v TransitiveSet<'v>>) -> anyhow::Result<Vec<Value<'v>>> {
Ok(this.typed.children.to_vec())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,23 @@ fn test_accessors() -> anyhow::Result<()> {
s2 = make_tset(FooSet, value = 1)
assert_eq(s2.value, 1)
"#
f4 = make_tset(FooSet, value = "baz")
assert_eq([], f4.children)
assert_eq([], [x.value for x in f4.children])
f3 = make_tset(FooSet, value = "bar", children = [f4])
assert_eq([f4], f3.children)
assert_eq(["baz"], [x.value for x in f3.children])
f2 = make_tset(FooSet, children = [f4, f3])
assert_eq([f4, f3], f2.children)
assert_eq(["baz", "bar"], [x.value for x in f2.children])
f1 = make_tset(FooSet, children = [f4, f3, f2])
assert_eq([f4, f3, f2], f1.children)
assert_eq(["baz", "bar"], filter(None, [x.value for x in f1.children]))
"#
))?;

Ok(())
Expand Down

0 comments on commit b15f709

Please sign in to comment.