]> git.lizzy.rs Git - rust.git/commitdiff
add should_panic annotations
authorJane Lusby <jlusby@yaah.dev>
Thu, 14 Apr 2022 20:22:24 +0000 (13:22 -0700)
committerJane Lusby <jlusby@yaah.dev>
Thu, 14 Apr 2022 20:22:24 +0000 (13:22 -0700)
library/core/src/result.rs

index 6189000cd36c1a0af1b80da547f60a4955b63afb..8a68e3fe6d6b4ebd2b94ea781ab4492d1df7a38e 100644 (file)
@@ -1034,7 +1034,7 @@ pub fn iter_mut(&mut self) -> IterMut<'_, T> {
     /// In the former case the expect message is used to describe the error that has occurred which
     /// is considered a bug. Consider the following example:
     ///
-    /// ```
+    /// ```should_panic
     /// // Read environment variable, panic if it is not present
     /// let path = std::env::var("IMPORTANT_PATH").unwrap();
     /// ```
@@ -1042,7 +1042,7 @@ pub fn iter_mut(&mut self) -> IterMut<'_, T> {
     /// In the "expect as error message" style we would use expect to describe that the environment
     /// variable was not set when it should have been:
     ///
-    /// ```
+    /// ```should_panic
     /// let path = std::env::var("IMPORTANT_PATH")
     ///     .expect("env variable `IMPORTANT_PATH` is not set");
     /// ```
@@ -1050,7 +1050,7 @@ pub fn iter_mut(&mut self) -> IterMut<'_, T> {
     /// In the latter style, we would instead describe the reason we _expect_ the `Result` will
     /// always be `Ok`. With this style we would instead write:
     ///
-    /// ```
+    /// ```should_panic
     /// let path = std::env::var("IMPORTANT_PATH")
     ///     .expect("env variable `IMPORTANT_PATH` is always be set by `wrapper_script.sh`");
     /// ```