Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that README code example is up to date #1017

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ unicode-xid = "0.2"

[dev-dependencies]
anyhow = "1.0"
doc-comment = "0.3"
flate2 = "1.0"
insta = "1.0"
rayon = "1.0"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub trait HeapSize {
The derive macro allows users to write `#[derive(HeapSize)]` on data structures
in their program.

```rust
```rust,ignore
#[derive(HeapSize)]
struct Demo<'a, T: ?Sized> {
a: Box<T>,
Expand All @@ -138,7 +138,7 @@ The token-based procedural macro API provides great control over where the
compiler's error messages are displayed in user code. Consider the error the
user sees if one of their field types does not implement `HeapSize`.

```rust
```rust,ignore
#[derive(HeapSize)]
struct Broken {
ok: String,
Expand All @@ -150,7 +150,7 @@ By tracking span information all the way through the expansion of a procedural
macro as shown in the `heapsize` example, token-based macros in Syn are able to
trigger errors that directly pinpoint the source of the problem.

```
```text
error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
--> src/main.rs:7:5
|
Expand All @@ -171,7 +171,7 @@ Syn's parsing API.
The example reimplements the popular `lazy_static` crate from crates.io as a
procedural macro.

```
```rust,ignore
lazy_static! {
static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap();
}
Expand All @@ -180,7 +180,7 @@ lazy_static! {
The implementation shows how to trigger custom warnings and error messages on
the macro input.

```
```text
warning: come on, pick a more creative name
--> src/main.rs:10:16
|
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ extern crate unicode_xid;
#[cfg(feature = "printing")]
extern crate quote;

#[cfg(doctest)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this increases MSRV to 1.40. BurntSushi/termcolor#35

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outch, good point!

#[macro_use]
extern crate doc_comment;

#[cfg(doctest)]
doctest!("../README.md");

#[macro_use]
mod macros;

Expand Down