Skip to content

Consider swapping permutohedron::control::Control & friends with std::ops::ControlFlow #10

@schneiderfelipe

Description

@schneiderfelipe

This (in fact the whole file)

/// Control flow for callbacks.
///
/// `Break` can carry a value.
#[derive(Copy, Clone, Debug)]
pub enum Control<B> {
Continue,
Break(B),
}

could be swapped with std::ops::ControlFlow, available since Rust 1.55.0.

But signatures like

permutohedron/src/lib.rs

Lines 44 to 46 in afdb943

pub fn heap_recursive<T, F, C>(xs: &mut [T], mut f: F) -> C
where F: FnMut(&mut [T]) -> C,
C: ControlFlow,

would become (something like)

pub fn heap_recursive<T, F, B, C>(xs: &mut [T], mut f: F) -> std::ops::ControlFlow<B, C>
    where F: FnMut(&mut [T]) -> std::ops::ControlFlow<B, C>,

or maybe even

pub fn heap_recursive<T, F, B, C>(xs: &mut [T], mut f: F) -> Result<C, B>
    where F: FnMut(&mut [T]) -> std::ops::ControlFlow<B, C>,

since std::ops::Try is not yet stable (rust-lang/rust#84277); that would be a breaking change.

What do you think @bluss?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions