Example viewer on docs - self contained examples

Hi all! I addressed a issue which could fit more be a feature request to rust in cargo, to avoid copy/paste, pls first read this one, describe the feature request:

I wanted to create a issue on the rust-lang/rust github page but it redirects here.

Seems there is several ways to handle this issue, and is more complex than I thought.

This issue also hit me when I was learning, and some time ago when I was teaching rust.