Skip to content

Commit 62d4277

Browse files
authored
Fix test in typespec_macros README (Azure#3050)
1 parent 77984ce commit 62d4277

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

sdk/typespec/typespec_macros/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The TypeSpec Macros crate provides procedural macros for [TypeSpec](https://type
1212

1313
This crate provides the following derive macros:
1414

15-
- `SafeDebug`: A derive macro that implements debug formatting in a way that avoids leaking personally identifiable information (PII).
15+
- `SafeDebug`: A derive macro that implements debug formatting in a way that avoids leaking personally identifiable information (PII).
1616

1717
### The SafeDebug derive macro
1818

@@ -31,11 +31,23 @@ struct Credentials {
3131
pub username: String,
3232
pub password: String,
3333
};
34-
let credentials: Credentials = Credentials {
34+
35+
let credentials = Credentials {
3536
username: "admin".into(),
3637
password: "hunter2".into(),
3738
};
38-
println!("{credentials:?}");
39+
40+
#[cfg(not(feature = "debug"))]
41+
assert_eq!(
42+
format!("{credentials:?}"),
43+
r#"Credentials { username: "admin", .. }"#,
44+
);
45+
46+
#[cfg(feature = "debug")]
47+
assert_eq!(
48+
format!("{credentials:?}"),
49+
r#"Credentials { username: "admin", password: "hunter2" }"#,
50+
);
3951
```
4052

4153
## Contributing

0 commit comments

Comments
 (0)