Skip to content

Update dtor-finally.md #415

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

Closed
wants to merge 1 commit into from
Closed

Conversation

AndreiTsN
Copy link
Contributor

I'm not sure, but it looks like a typo in the function name. Now, it's a 'baz', but I think it should be 'bar'.

I'm not sure, but it looks like a typo in the function name.
Now, it's a 'baz', but I think it should be 'bar'.
@marcoieni
Copy link
Collaborator

I think here "baz" just means "run another function". Otherwise the recursion never ends.

@marcoieni marcoieni closed this Aug 30, 2024
@AndreiTsN
Copy link
Contributor Author

AndreiTsN commented Aug 30, 2024

Hi, Marco. Thank you for your response!
In fact, as I can see, recursion ends up in a stack overflow (and the expected 'drop'=finally call won't happen and we get a good example of 'Disadvantages'). Anyway, it'll be good to have more clarifications here if 'baz' is correct. What do you think?

@marcoieni
Copy link
Collaborator

it'll be good to have more clarifications here if 'baz' is correct

How can we achieve this?

@AndreiTsN AndreiTsN deleted the patch-1 branch August 30, 2024 13:50
@AndreiTsN AndreiTsN restored the patch-1 branch August 30, 2024 13:50
@AndreiTsN
Copy link
Contributor Author

AndreiTsN commented Aug 30, 2024

I think, the simplest way:

fn baz( ) -> Result<( ), ( )> {
// some code
}

fn bar( ) -> Result<( ), ( )> {
...
baz( )?;
// Normal return.
Ok(( ))
}

But of course, the code can be left as it is now.
It's absolutely not critical.

@marcoieni
Copy link
Collaborator

this sounds like a great idea, pr welcome 🙌

@AndreiTsN
Copy link
Contributor Author

thanks a lot! A new pr added.

@AndreiTsN AndreiTsN deleted the patch-1 branch September 1, 2024 10:36
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