News for hackers. Stuff that matters.
Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by voorwerpjes on Wednesday October 05, 2022 @02:00AM (#33091827)
Very cool!

I don't understand the motivation about lifetimes in sync rust not being able to be arbitrary. I'm also confused because most of the time went you want to send data around in a async context you wrap it in `arc`, which has the pretty much analogous `rc` in a sync context which would also solve the lifetimes issue. Is there something I am missing?

Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by sakex on Wednesday October 05, 2022 @03:50AM (#33092525)
In C++, this will compile:

    class T {
        public:
            T(int & m): member{m} {}
            int & member;
    }

    T MakeT(int m) {
        return T(m);
    }
    
    int main() {
        const auto t = MakeT(10);
        std::cout << t.member << std::endl; // UB <- member has actually been destroyed
    }
Rust will correctly observe that the lifetime of m in `MakeT` is lower than the T object returned and will refuse to compile