-
Notifications
You must be signed in to change notification settings - Fork 33
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
Type annotations #33
Comments
I don't see you yielding anywhere in this example. |
Unfortunately, "terrible compilation errors" is going to be a limitation of this crate & the macro strategy. Doing better on the compilation error front will require rustc to provide stream generators. Sorry :( |
Sorry, the yield was in the part that was omitted in the error message 🙂 Sure, that's fine, I just wondered whether there's an easy way to annotate the return type, so that I won't have to create a helper function. But helper functions work just fine. |
I managed to annotate the return type by writing this: let stream = try_stream! {
//...
};
let _: &dyn Stream<Item=Result<_, MyError>> = &stream; Not the prettiest code, but it gets the job done and looks better than the auxiliary function. |
Often I get compile errors when the compiler cannot deduce the type when using
try_stream!
:This can be resolved by moving the code into a function that returns the appropriate generic type. However, is it also possible to put a type annotation somewhere? (
impl T
doesn't seem to work for annotating the type of a local variable.)The text was updated successfully, but these errors were encountered: