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.
> 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.
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.
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.
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.