How to use documentation example for `std::ops::ControlFlow`?

The documentation page for ControlFlow features a basic visitor implementation.
Unfortunately, it is not clear to me how to actually use this method. For example, this call fails with a compilation error. Also using a &mut || closure fails.

I had to modify the example code like this to make it usable:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0b534dc88883f0ebd67774f56a857da2

2 Likes

Good catch! I wrote that in the RFC and only checked that it compiled, not that it was callable :sweat_smile:

I've opened a bug to track fixing it: `traverse_inorder` example in `ControlFlow` compiles, but can't be called · Issue #90063 · rust-lang/rust · GitHub

EDIT: And it looks like someone's already claimed it. Thanks, community!

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.