Skip to content

Feature request: pop arbitrary entry. #156

@bentheiii

Description

@bentheiii

When attempting to implement a pool with slab, we have a need to access/pop an arbitrary element. I propose the api

impl<T> Slab<T>{
  pub fn take(&mut self)->Option<T>{
    ...
  }
}

Which will remove and return an arbitrary element (if one exists). As for implementation, it seems simple enough to always remove and return the element at self.next - 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions