notionrs_schema/macro/
impl_display_from_string_field.rs

1/// Implement `Display` trait for a struct that has a field of type `String`.
2///
3///
4/// ```ignore
5/// impl std::fmt::Display for BookmarkBlock {
6///     fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7///         write!(f, "{}", self.url)
8///     }
9/// }
10/// ```
11/// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
12/// ```ignore
13/// crate::impl_display_from_string_field!(BookmarkBlock, url);
14/// ```
15#[macro_export]
16macro_rules! impl_display_from_string_field {
17    ($struct_name:ident, $field:ident) => {
18        impl std::fmt::Display for $struct_name {
19            fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
20                write!(f, "{}", self.$field)
21            }
22        }
23    };
24}