Hacker Newsnew | past | comments | ask | show | jobs | submit | cypressious's commentslogin

It seems Rust's unwrap is the exact opposite of ?? "". It throws an error instead of using a fallback value, which is exactly what the author suggests instead of using ?? "".


Author here. I believe I did a poor job of explaining what I meant by this sentence in the article. Sorry about that.

As you, and many others, have pointed out, `?? ""` does not do what `.unwrap` does. `unwrap_or_default` would have been a better comparison for what it actually does. What I tried, and failed, to communicate, was that both can be used to "ignore" the unwanted state, `None` or `undefined`.

I guess the rust equivalent to what I would like to see is `nullable_var?`, and not unwrap as that will panic. That would be equivalent to the `?? throw new Error` feature mentioned further up in the comments.


From the article:

> In Rust, however, you're forced to reason about the "seriousness" of calling .unwrap() as it could terminate your program. In TS you're not faced with the same consequences.


Yes that was a mistake.

unwrap() is the error.

unwrap_or() is the fallback.


Also unwrap_or_default() which is useful in many cases. For example the default for a string is empty string, default for integers is 0 and default for bool is false.

For your own types you can implement the Default trait to tell Rust what the default value is for that type.



Web notifications are opt-in.


If you use the the Gradle wrapper, it will use the correct version and download it if necessary. If I'm not mistaken, that's the recommended approach.


It's explicitly allowed to be used for content creation.


I really enjoy projects where the project and the scripts around it use the same language.


I find that sticking to a single stack is severely underrated.


Impressive. Funny that one thing they got wrong is cars becoming smaller instead of bigger.


If you could get 5 self-driving single seaters instead of one 5-seater for the same price... probably the 5-seater wins.

But if you can call a reliable self-driving one-seater within 5 minutes guaranteed?


Many years ago, I changed my YouTube bookmark to go directly to the subs page. Can recommend.


You could serialize the JS representation to Base64 or Base10 if you want it to be numeric.


But that's a lot more data than just storing which of the ~2^50 possible faces was generated. You could serialize the entire face including the colors and scaling factors into a much smaller string, or just take one number that is used as a seed for a random number generator that sets the other parameters


The seed version with random parameters doesn't allow you to or your users to design their own. Just random selection until you get one you like, no editing of details.


Android forces app developers to categorize notifications (the API is called notification channels). Each channel can be muted individually in the system settings. Though it's up to the app makers to correctly categorize their notifications, in my experience most apps do this.

Whenever I see a spam notification, I immediatelly go mute the channel and the problem never repeats itself.


The problem is still bad actors. Take for example audible. They deliberately put everything into a single category "Member notifications"

If you want to know when your audiobook is downloaded or when you get a your next credit is available, you also have to put up with promotional "X book is 40% off" garbage spam.


> Android forces app developers to categorize notifications (the API is called notification channels).

There's nothing to force you to be honest. It only forces you to specify a channel when you post a notification. You can as well just create a single one for everything, which is exactly what some apps do.


I have a Samsung and it doesn't show what channel a notification came from. Probably because of the amount of crapware Samsung bundles.


It shows, though it's a bit obscure. Long press the notification, then press notification settings. It will scroll you down and highlight the notification channels item. Press on it. After a second, it will highlight the channel the original notification was belonging to.


That's not "a bit obscure". That's almost completely hidden.


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

Search: