Skip to content

try_* methods for containers #39

Open
@Ericson2314

Description

@Ericson2314

Given that #23 is closed, the API looks something like:

// OnOomError is a variable, `try_*` is always available
fn try_push(&mut self: Vec<T, A: AllocRef, OnOomError>, t: T) -> Result<(), (AllocError, T)> { .. }

// NoAbort is a data type, used as a sentinel indicating the consumer is prohibited from using the aborting methods.
struct NoAbort();

// Abort is a data type, used as a sentinel indicating the consumer is allowed to use the aborting methods.
struct Abort();

fn push(&mut self: Vec<T, A: AllocRef, Abort>, t: T) -> T {
   match self.push(t) {
     OK(v) => v,
     Err(e) => handle_alloc_error(e),
  }
}

Per https://rust-lang.zulipchat.com/#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Design.20of.20.60AbortAlloc.60.20not.20compatible.20with.20.60try_reserve.60

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