Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Commit

Permalink
Remove routes macro example
Browse files Browse the repository at this point in the history
The same content is covered better by the getters example.
  • Loading branch information
dtolnay committed Jul 26, 2020
1 parent c089c81 commit 40db57a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 53 deletions.
29 changes: 3 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,11 @@ fn main() {

<br>

## More elaborate examples

This program demonstrates how you may want to bundle a paste invocation inside
of a more convenient user-facing macro of your own. Here the `routes!(A, B)`
macro expands to a vector containing `ROUTE_A` and `ROUTE_B`.

```rust
use paste::paste;

const ROUTE_A: &str = "/a";
const ROUTE_B: &str = "/b";

macro_rules! routes {
($($route:ident),*) => {{
paste! {
vec![$( [<ROUTE_ $route>] ),*]
}
}}
}

fn main() {
let routes = routes!(A, B);
assert_eq!(routes, vec!["/a", "/b"]);
}
```
## More elaborate example

The next example shows a macro that generates accessor methods for some struct
fields.
fields. It demonstrates how you might find it useful to bundle a paste
invocation inside of a macro\_rules macro.

```rust
use paste::paste;
Expand Down
31 changes: 4 additions & 27 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,11 @@
//!
//! <br><br>
//!
//! # More elaborate examples
//! # More elaborate example
//!
//! This program demonstrates how you may want to bundle a paste invocation inside
//! of a more convenient user-facing macro of your own. Here the `routes!(A, B)`
//! macro expands to a vector containing `ROUTE_A` and `ROUTE_B`.
//!
//! ```
//! use paste::paste;
//!
//! const ROUTE_A: &str = "/a";
//! const ROUTE_B: &str = "/b";
//!
//! macro_rules! routes {
//! ($($route:ident),*) => {{
//! paste! {
//! vec![$( [<ROUTE_ $route>] ),*]
//! }
//! }}
//! }
//!
//! fn main() {
//! let routes = routes!(A, B);
//! assert_eq!(routes, vec!["/a", "/b"]);
//! }
//! ```
//!
//! The next example shows a macro that generates accessor methods for some struct
//! fields.
//! The next example shows a macro that generates accessor methods for some
//! struct fields. It demonstrates how you might find it useful to bundle a
//! paste invocation inside of a macro\_rules macro.
//!
//! ```
//! use paste::paste;
Expand Down

0 comments on commit 40db57a

Please sign in to comment.