Skip to content

Make functional programming not so inconvenient #13765

Closed
@eduardoleon

Description

@eduardoleon

The latest Rust nightly build removed the ability to call closures from immutable references. This breaks my library and forces me to replace closures with trait objects that expose methods that are morally operator()s like:

pub trait CallableOnce<T, U> {
    fn only_call(self, x: T) -> U;
}

pub trait CallableManyTimes<T, U> : CallableOnce<T, U> {
    fn one_call_amongst_many(&self, x: T) -> U;
}

Normally, I can work around the changes introduced in every nightly build. However, this particular change significantly reduces the usability of my library, because it forces the programmer to use C++-style function objects, and by this time we should already know how "convenient" that is. My primary motivation for making rust-stl is to show that it is possible, with the right type system, to eat one's cake and have it too, to combine the elegance of Haskell/ML-style functional programming with the efficiency of C++. I want Rust to be the language that helps me make this case, and for the most part it has worked beautifully, but this time it did not.

Please do something about it.

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