Skip to content

Commit 460c013

Browse files
committed
fixup doctests
Signed-off-by: tison <[email protected]>
1 parent 4af5cd8 commit 460c013

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

fastrace/src/macros.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ macro_rules! func_name {
3131
///
3232
/// # Example
3333
///
34-
/// ```no_run
34+
/// ```
3535
/// use fastrace::func_path;
3636
///
3737
/// fn foo() {
38-
/// assert_eq!(func_path!(), "doctest_bundle_2024::__doctest_39::main::foo");
38+
/// let path = func_path!();
39+
/// assert!(path.ends_with("::foo"), "{path} should end with ::foo");
3940
/// }
4041
/// # foo()
42+
/// ```
4143
#[macro_export]
4244
macro_rules! func_path {
4345
() => {{
@@ -69,13 +71,27 @@ macro_rules! full_name {
6971
///
7072
/// # Example
7173
///
72-
/// ```no_run
74+
/// ```
7375
/// use fastrace::file_location;
7476
///
7577
/// fn foo() {
76-
/// assert_eq!(file_location!(), "fastrace/src/macros.rs:8:15");
78+
/// let loc = file_location!();
79+
/// let mut parts = loc.rsplitn(3, ':');
80+
/// let file = parts.next().unwrap();
81+
/// let line = parts.next().unwrap();
82+
/// let column = parts.next().unwrap();
83+
/// assert!(file.ends_with(".rs"), "{file} should end with .rs");
84+
/// assert!(
85+
/// line.parse::<u32>().is_ok(),
86+
/// "{line} should be a valid line number"
87+
/// );
88+
/// assert!(
89+
/// column.parse::<u32>().is_ok(),
90+
/// "{column} should be a valid column number"
91+
/// );
7792
/// }
7893
/// # foo()
94+
/// ```
7995
#[macro_export]
8096
macro_rules! file_location {
8197
() => {

0 commit comments

Comments
 (0)