|
|
|
|
|
by jsfitzsimmons
3349 days ago
|
|
It's not really that innocuous. It'll cause the program to crash as soon as it's discovered that there wasn't a value where you were expecting one. In languages with exceptions, the program will crash as soon as you try to use that value (rather than when you try to unwrap it), e.g. the infamous null pointer exception. Copying bad sample code in this case might result in code that is difficult to debug because a null value might be handed off several times before something tries to dereference it. In languages that expect but do not enforce that you check the validity of the value (like C) you'll just get undefined behaviour that will hopefully cause your program to segfault when you try to use the value, but who knows what will actually happen? Copying bad sample code in this case will cause a security vulnerability. Copying "bad" sample rust code (using unwrap) will cause a safe crash with maximum locality, for simpler debugging. |
|