Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- println!("{:?}", {
- fn foo(a: Option<i32>, b: Option<i32>) -> Option<i32> { let c = (|| a? + b?); c }
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (file:///playground)
- warning: unnecessary parentheses around assigned value
- --> src/main.rs:5:73
- |
- 5 | fn foo(a: Option<i32>, b: Option<i32>) -> Option<i32> { let c = (|| a? + b?); c }
- | ^^^^^^^^^^^^ help: remove these parentheses
- |
- = note: #[warn(unused_parens)] on by default
- error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
- --> src/main.rs:5:77
- |
- 5 | fn foo(a: Option<i32>, b: Option<i32>) -> Option<i32> { let c = (|| a? + b?); c }
- | ^^ cannot use the `?` operator in a function that returns `i32`
- |
- = help: the trait `std::ops::Try` is not implemented for `i32`
- = note: required by `std::ops::Try::from_error`
- error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
- --> src/main.rs:5:82
- |
- 5 | fn foo(a: Option<i32>, b: Option<i32>) -> Option<i32> { let c = (|| a? + b?); c }
- | ^^ cannot use the `?` operator in a function that returns `i32`
- |
- = help: the trait `std::ops::Try` is not implemented for `i32`
- = note: required by `std::ops::Try::from_error`
- error[E0308]: mismatched types
- --> src/main.rs:5:87
- |
- 5 | fn foo(a: Option<i32>, b: Option<i32>) -> Option<i32> { let c = (|| a? + b?); c }
- | ----------- ^ expected enum `std::option::Option`, found closure
- | |
- | expected `std::option::Option<i32>` because of return type
- |
- = note: expected type `std::option::Option<i32>`
- found type `[closure@src/main.rs:5:73: 5:85 a:_, b:_]`
- error: aborting due to 3 previous errors
- Some errors occurred: E0277, E0308.
- For more information about an error, try `rustc --explain E0277`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Add Comment
Please, Sign In to add comment