logoalt Hacker News

stonogo • today at 5:47 AM • 2 replies • view on HN

I'm pretty familiar with Rust at this point but I'll never look at something like

    fn view(_: &()) -> impl Widget<()> {
and think "nailed it"

Replies

ordu • today at 8:30 AM

Why? () is an empty type, it is used here twice because... well it is a hello-world example, they don't need any state to render, but API expects you to pass a reference to a state, so they use &() and _ as a placeholder for an arg name. And Widget gets () as a type parameter for the same reason.

Pretty straightforward to my mind.

jensen_is_goat • today at 8:25 AM

[dead]