Skip to content

Support Vec .push and .extend with the new TryClone trait #7

@amunra

Description

@amunra

It would be nice if Rust had an explicit way to distinguish alloc-free cloning vs alloc-dependent cloning, but his isn't there, as such existing implementations for element push / extend still rely on the Clone trait and we're simply hoping for the best.

I don't think that will change, but since we've introduced a new TryClone trait that allows failing gracefully on allocation errors, we should support this in our API too.

A basic use case is simply having vectors of vectors. The following should work:

let mut v: Vec<Vec<i32, MyAlloc>, MyAlloc> = Vec::new_in(alloc);
v.extend(...)?;

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