Skip to content

Commit 148c026

Browse files
committed
refactor: Move crate_name out into a file
1 parent a096861 commit 148c026

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/lib.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,7 @@
104104
#![warn(clippy::print_stderr)]
105105
#![warn(clippy::print_stdout)]
106106

107-
/// Allows you to pull the name from your Cargo.toml at compile time.
108-
///
109-
/// # Examples
110-
///
111-
/// ```should_panic
112-
/// use assert_cmd::Command;
113-
///
114-
/// let mut cmd = Command::cargo_bin(assert_cmd::crate_name!()).unwrap();
115-
/// let assert = cmd
116-
/// .arg("-A")
117-
/// .env("stdout", "hello")
118-
/// .env("exit", "42")
119-
/// .write_stdin("42")
120-
/// .assert();
121-
/// assert
122-
/// .failure()
123-
/// .code(42)
124-
/// .stdout("hello\n");
125-
/// ```
126-
#[macro_export]
127-
macro_rules! crate_name {
128-
() => {
129-
env!("CARGO_PKG_NAME")
130-
};
131-
}
107+
mod macros;
132108

133109
pub mod assert;
134110
pub mod cargo;

src/macros.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// Allows you to pull the name from your Cargo.toml at compile time.
2+
///
3+
/// # Examples
4+
///
5+
/// ```should_panic
6+
/// use assert_cmd::Command;
7+
///
8+
/// let mut cmd = Command::cargo_bin(assert_cmd::crate_name!()).unwrap();
9+
/// let assert = cmd
10+
/// .arg("-A")
11+
/// .env("stdout", "hello")
12+
/// .env("exit", "42")
13+
/// .write_stdin("42")
14+
/// .assert();
15+
/// assert
16+
/// .failure()
17+
/// .code(42)
18+
/// .stdout("hello\n");
19+
/// ```
20+
#[macro_export]
21+
macro_rules! crate_name {
22+
() => {
23+
env!("CARGO_PKG_NAME")
24+
};
25+
}

0 commit comments

Comments
 (0)