Update example in RFC 2345 to have format argument

The panic error message now has an argument for the format.
This commit is contained in:
mbartlett21 2020-11-10 19:34:39 +10:00 committed by GitHub
parent 24cf67ad56
commit b180cc3a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ const fn parse_bool(s: &str) -> bool {
match s {
"true" => true,
"false" => false,
other => panic!("`{}` is not a valid bool"),
other => panic!("`{}` is not a valid bool", other),
}
}
parse_bool("true");
@ -50,8 +50,8 @@ will produce an error with your custom error message:
error[E0080]: `foo` is not a valid bool
--> src/main.rs: 5:25
|
5 | other => panic!("`{}` is not a valid bool"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 | other => panic!("`{}` is not a valid bool", other),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: during the evaluation of
|
10 | parse_bool("foo");