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

feat: support Result-based error handling in init methods #754

Merged
merged 5 commits into from
Mar 17, 2022

Conversation

itegulov
Copy link
Contributor

While refactoring lockable-ft example in #750 I realized that init methods could also benefit from Result-based error handling. Also realized that I forgot to throw an error when a method that does not return Result is marked with #[return_result].

Comment on lines 849 to 851
#[init(ignore_state)]
#[return_result]
pub fn new() -> Result<Self, &'static str> { }
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, so this annotation is a bit misleading when used with init because nothing is actually returned. I wonder if there is a better name for this annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, not the best name for sure. How about #[handle_result_error] or even #[handle_result]?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, not the best name for sure. How about #[handle_result_error] or even #[handle_result]?

I personally like the latter since it's more concise (result_error is a bit redundant), but up to you!

Copy link
Member

@ChaoticTempest ChaoticTempest left a comment

Choose a reason for hiding this comment

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

LGTM. And man they changed the Github Files changed page 🙃

@itegulov
Copy link
Contributor Author

itegulov commented Mar 17, 2022

@ChaoticTempest haha, are you talking about the file tree view? I thought it was only available as a feature preview. Enabled it a few days ago and am very happy that they are finally adding something like this 😄

@itegulov itegulov merged commit 4aef1e2 into master Mar 17, 2022
@itegulov itegulov deleted the daniyar/improve-result-handling branch March 17, 2022 01:26
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.

3 participants