Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update return signature for try_from_os_str #3818

Merged
merged 2 commits into from Jun 14, 2022

Conversation

mbhall88
Copy link
Contributor

Small documentation fix to update the documentedt expected signature of try_from_os_str. The error type of the return Result was stated as OsString, but it is actually String. This is confirmed by this test

fn custom_parser_4(_: &OsStr) -> Result<&'static str, String> {

When I was trying to use OsString I was unable to compile with the error error[E0277]: `OsString` doesn't implement `std::fmt::Display` . Changing the error type to String fixed this.

@mbhall88 mbhall88 changed the title update return signature for try_from_os_str docs: update return signature for try_from_os_str Jun 13, 2022
@@ -268,7 +268,7 @@ You can then support your custom type with `#[clap(parse(<kind> [= <function>]))
| `from_str` | `fn(&str) -> T` | `::std::convert::From::from` |
| `try_from_str` (default) | `fn(&str) -> Result<T, E>` | `::std::str::FromStr::from_str` |
| `from_os_str` | `fn(&OsStr) -> T` | `::std::convert::From::from` |
| `try_from_os_str` | `fn(&OsStr) -> Result<T, OsString>` | (no default function) |
| `try_from_os_str` | `fn(&OsStr) -> Result<T, String>` | (no default function) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was trying to use OsString I was unable to compile with the error error[E0277]: OsString doesn't implement std::fmt::Display . Changing the error type to String fixed this.

Sounds like this should be E like try_from_str's signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in the latest commit

@epage
Copy link
Member

epage commented Jun 14, 2022

Thanks!

@epage epage merged commit 1ba6ef9 into clap-rs:master Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants