Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 865 Bytes

template-example.md

File metadata and controls

35 lines (25 loc) · 865 Bytes

Skeptic Template Example

This is an example of Rust Skeptic Templates. See README.md for the main documentation.

Templates allow you to explicitly perform some of the automatic transformations that rustdoc does on code examples.

In this document we will automatically inject extern crate skeptic;, turn off unused imports, and wrap the example in main:

```rust,skeptic-template

#![allow(unused_imports)]
extern crate skeptic;

fn main() {{
   {}
}}

```

Note that this is a Rust format specifier, so braces are treated specially, and need to be escaped with double-braces.

Now, examples we write here can take some shortcuts:

use skeptic::generate_doc_tests;

let _cant_do_this_without_main = 0;