hubcaps
hubcaps copied to clipboard
IssueOptions::new doesn't take `None` for Assignee's
When attempting to provide None for Assignee, you get a compilation error since None can't be converted into a String
error[E0283]: type annotations required: cannot resolve `_: std::convert::Into<std::string::String>`
--> src/main.rs:30:22
|
30 | .create(&IssueOptions::new(
| ^^^^^^^^^^^^^^^^^
|
= note: required by `hubcaps::issues::IssueOptions::new`
Example code causing this error:
github.repo("softprops", "hubcaps")
.issues()
.create(&IssueOptions::new(
"test issue",
Some("What The Title Says"),
None,
None,
vec!["bug"],
))
This conversion should be skipped if assignees is provided as None
I'll take a closer look this weekend
Realizing now this is kind of a crappy interface for type inference because the compiler can't infer much implicitly from None types with out a bit more explicit info. You can work around this with the following type ascriptions
github.repo("softprops", "hubcaps").issues().create(
&IssueOptions::new::<_, &str, &str, _>(
"test issue",
Some("What The Title Says"),
None,
None,
vec!["bug"],
),
);
I'm going to think about about a better design
Thanks for the update!
Alternative versions
// #1
let assignee: Option<String> = None;
IssueOptions::new(
"test issue",
Some("What The Title Says"),
assignee,
None,
vec!["bug"],
);
// #2
IssueOptions::new(
"test issue",
Some("What The Title Says"),
None::<String>,
None,
vec!["bug"],
);