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

How to insert node(s) at specified index or before existing node? #61

Open
katyo opened this issue Jan 12, 2020 · 2 comments
Open

How to insert node(s) at specified index or before existing node? #61

katyo opened this issue Jan 12, 2020 · 2 comments

Comments

@katyo
Copy link

katyo commented Jan 12, 2020

Currently is this a missing feature?

I see only add_child () which likely insert children at end, and set_children() which reloads all children, also it has replace_child_at_index() but I want to insert new node without removing existing node.

@katyo
Copy link
Author

katyo commented Jan 12, 2020

I think I would like to have the method replace_children() as defined below:

pub enum Placement {
    AtStart,
    AtEnd,
    AtIndex(usize),
    BeforeNode(Node),
}

// ...

impl Stretch {
    // ...
    fn replace_children<I>(&mut self,
                           node: Node,
                           place: Placement,
                           remove: usize,
                           insert: I) -> Vec<Node>
    where
        I: IntoIterator<Item = Node>;
    // ...
}

@katyo
Copy link
Author

katyo commented Jan 12, 2020

The another option is the DOM-like API but in practice it not so usable.

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

1 participant