Code paths

Some paths should never be traversed and, in our code, that is usually a condition for our code to work properly. If we are receiving bad input data, we might want to return an error, but if our library is being misused, we might prefer to panic. Sometimes, we also want to make sure that it's impossible for a variable to be out of some bounds once it gets to the logic of our function, to avoid security flaws, for example. In those cases, the unreachable!() macro, or even the explicit panic!() macro, can help us.

There is another path that might not be ready to be traversed yet. While our crate is being implemented, we can use the unimplemented!() macro, as we saw before in some examples, to indicate that the code we are writing is not implemented. This will enable the code to compile but, if executed, it will panic with the not yet implemented message.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.72.74