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

Commit 73a54c0

Browse files
committed
Make method_new example compilable
1 parent 23f7fac commit 73a54c0

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,13 @@ use paste::paste;
127127

128128
macro_rules! method_new {
129129
($ret:ident) => {
130-
paste! {
131-
#[doc = "Create a new `" $ret "` object."]
132-
pub fn new() -> $ret { todo!() }
130+
pub struct $ret {}
131+
132+
impl $ret {
133+
paste! {
134+
#[doc = "Create a new `" $ret "` object."]
135+
pub fn new() -> $ret { todo!() }
136+
}
133137
}
134138
};
135139
}

src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,17 @@
125125
//!
126126
//! macro_rules! method_new {
127127
//! ($ret:ident) => {
128-
//! paste! {
129-
//! #[doc = "Create a new `" $ret "` object."]
130-
//! pub fn new() -> $ret { todo!() }
128+
//! pub struct $ret {}
129+
//!
130+
//! impl $ret {
131+
//! paste! {
132+
//! #[doc = "Create a new `" $ret "` object."]
133+
//! pub fn new() -> $ret { todo!() }
134+
//! }
131135
//! }
132136
//! };
133137
//! }
134138
//!
135-
//! # struct Paste;
136139
//! method_new!(Paste); // expands to #[doc = "Create a new `Paste` object"]
137140
//! ```
138141

0 commit comments

Comments
 (0)