I suppose you noticed that we never added a function or anything. So how does it actually work?
Well first, it checks if the main function is defined. If not, it'll wrap the code into one. Observe the following code:
/// ``` /// let x = 0; /// ```
When you write the preceding code, it gets transformed into this:
/// ``` /// fn main() { /// let x = 0; /// } /// ```
Also, you can use all the public items defined in your crate in your code blocks. No need to import the crate with an extern crate (however, you still have to import the item!).
One last (very) important point remains to be talked about: hiding code blocks lines.