Skip to content

Instantly share code, notes, and snippets.

@func-hs
Created February 16, 2018 01:59
Show Gist options
  • Save func-hs/c08a87dab7c326fea321589ecb7b0737 to your computer and use it in GitHub Desktop.
Save func-hs/c08a87dab7c326fea321589ecb7b0737 to your computer and use it in GitHub Desktop.
マクロの引数を間違えた場合
$ rustc test.rs
error[E0308]: mismatched types
--> test.rs:2:35
|
2 | let r: Result<(), &str> = Err(format!("hello!"));
| ^^^^^^^^^^^^^^^^^
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&format!("hello!")`
|
= note: expected type `&str`
found type `std::string::String`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
fn main() {
let r: Result<(), &str> = Err(format!("hello!"));
println!("{:?}", r);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment