Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Loved the article, such a nice read. I am still slowly ramping up my proficiency in Rust and this gave me a lot of things to think through. I particularly enjoyed the temporary mutability pattern, very cool and didn't think about it before!




> I particularly enjoyed the temporary mutability pattern, very cool and didn't think about it before!

It's not too uncommon in other languages (sometimes under the name "immediately invoked function expression"), though depending on the language you may see lambdas involved. For example, here's one of the examples from the article ported to C++:

    auto data = []() {
        auto data = get_vector();
        auto temp = compute_something();
        data.insert_range(data.end(), temp);
        std::ranges::sort(data);
        return data;
    }();



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: