#rustlang can yinz give me a concrete example of a case in your code (not stdlib) when you would want to call `panic!`?
literally panic, although i would also love examples of assert in a non-test context!
-
-
you can use asserts in contract programming to assure your input is what you'd expect, forcing a crash when it's not
-
i can easily see going overboard with checking contracts though... where do you draw the line?
- 3 more replies
New conversation -
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I use lots of asserts when wrapping C libs: assert!(!p.is_null() && size < std::u32::MAX); assert_eq!(src.len(), dst.len());
-
I don't use Errors for them mostly because a) I'm lazy b) these are edge cases c) would be bugs in the C lib or violations of API contract
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.