]> git.lizzy.rs Git - rust.git/commitdiff
Add newlines in unwrap_or ui test
authorbootandy <bootandy@gmail.com>
Tue, 20 Feb 2018 17:37:30 +0000 (12:37 -0500)
committerbootandy <bootandy@gmail.com>
Tue, 20 Feb 2018 17:37:30 +0000 (12:37 -0500)
tests/ui/unwrap_or.rs
tests/ui/unwrap_or.stderr

index b95e58ee9a350cba06b1e4c9154840f071758b57..79e3900fef0e323d122787dbd089e796b88bf5c7 100644 (file)
@@ -3,3 +3,9 @@
 fn main() {
     let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len();
 }
+
+fn new_lines() {
+    let s = Some(String::from("test string"))
+        .unwrap_or("Fail".to_string())
+        .len();
+}
index e9bf57ba0ec63b18db25aee512ead7a8f4d527d8..ec5232d65a010c98320a892aae21e029736471b4 100644 (file)
@@ -6,5 +6,13 @@ error: use of `unwrap_or` followed by a function call
   |
   = note: `-D or-fun-call` implied by `-D warnings`
 
-error: aborting due to previous error
+error: use of `unwrap_or` followed by a function call
+ --> $DIR/unwrap_or.rs:8:46
+  |
+8 |       let s = Some(String::from("test string"))
+  |  ______________________________________________^
+9 | |         .unwrap_or("Fail".to_string())
+  | |______________________________________^ help: try this: `.unwrap_or_else(|| "Fail".to_string())`
+
+error: aborting due to 2 previous errors