Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get all children that are Groups (not Arrays) #103

Closed
niklasmueboe opened this issue Dec 19, 2024 · 3 comments
Closed

Get all children that are Groups (not Arrays) #103

niklasmueboe opened this issue Dec 19, 2024 · 3 comments

Comments

@niklasmueboe
Copy link
Contributor

Hi,
I was wondering what the best way is to get all children of a Group that are also Groups. Specifically I am only interested in the names of the children.

Currently I am trying this

Node::open(&store, "/")?
        .children()
        .into_iter()
        .filter_map(|node| {
            if matches!(node.metadata(), NodeMetadata::Group(_)) {
                Some(node.name().as_str().to_owned())
            } else {
                None
            }
        })
        .collect();

but was wondering whether there is a simpler way instead of matching on the metadata type. Also prefereably I would start with a Group already instead of creating a new node.

@LDeakin
Copy link
Owner

LDeakin commented Dec 20, 2024

That looks to be the way right now.

Also prefereably I would start with a Group already instead of creating a new node

+1. Group would greatly benefit from having methods to get child Groups / Arrays. Would you be interested in contributing such a feature?

@niklasmueboe
Copy link
Contributor Author

I started a draft #104

But some discussion on what the API should look like might be useful

@LDeakin
Copy link
Owner

LDeakin commented Dec 25, 2024

Closed by #104. Thanks @niklasmueboe

@LDeakin LDeakin closed this as completed Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants