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

Passing None for data results in compile error #1

Closed
jwilm opened this issue Nov 12, 2015 · 4 comments
Closed

Passing None for data results in compile error #1

jwilm opened this issue Nov 12, 2015 · 4 comments

Comments

@jwilm
Copy link
Owner

jwilm commented Nov 12, 2015

request is declared as

pub fn request<S, D>(method: Method, url: &str, data: Option<S>) -> Result<Option<D>>

The compiler errors when data is None because now the type S is undefined.

error: unable to infer enough type information about `_`; type annotations or generic parameter binding required

There is a failing test here which demonstrates the desired behavior.

@bluss
Copy link

bluss commented Nov 12, 2015

The type S matters, so it must be inferred somehow. In the future, with type param defaults properly turned on, you can set a default. For now you must choose a type, for example by hinting on the none: None::<Xyz>.

@jwilm
Copy link
Owner Author

jwilm commented Nov 12, 2015

What do you mean here?

with type param defaults properly turned on

Is that an upcoming language feature?

@bluss
Copy link

bluss commented Nov 12, 2015

Yep, see rust-lang/rust/issues/27336

It's an existing unstable feature, not stable yet.

@jwilm
Copy link
Owner Author

jwilm commented Nov 12, 2015

Thanks for the link.

reads

@jwilm jwilm closed this as completed in 9adbc57 Nov 12, 2015
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

No branches or pull requests

2 participants