Richard Schneeman on Nostr: I want to provide a format! like macro that applies a specific formatting to whatever ...
I want to provide a format! like macro that applies a specific formatting to whatever **values** are provided to the macro. For example
```
format!("Meet {}", dog)
// => format!("Meet {}", custom_fmt(dog))
format!("Meet {dog}")
// => format!("Meet {}", custom_fmt(dog))
format!("Meet {dog}", dog = animal)
// => format!("Meet {dog}", dog = custom_fmt(animal))
```
It seems like this shouldn't be a novel desire, but I'm not seeing a great path forward... #rustlang
Published at
2024-11-01 20:15:36Event JSON
{
"id": "773e393c3a3d79463882d001d5bab4fda8c149adace02863f9c62d6ad64bd18f",
"pubkey": "5c931aab4bd50aef18e4fd6a257cb53bb70fee015066bea9102ac27a8e230f5c",
"created_at": 1730492136,
"kind": 1,
"tags": [
[
"t",
"rustlang"
],
[
"proxy",
"https://ruby.social/users/Schneems/statuses/113409532668629218",
"activitypub"
]
],
"content": "I want to provide a format! like macro that applies a specific formatting to whatever **values** are provided to the macro. For example\n\n```\nformat!(\"Meet {}\", dog) \n// =\u003e format!(\"Meet {}\", custom_fmt(dog))\n\nformat!(\"Meet {dog}\") \n// =\u003e format!(\"Meet {}\", custom_fmt(dog))\n\nformat!(\"Meet {dog}\", dog = animal) \n// =\u003e format!(\"Meet {dog}\", dog = custom_fmt(animal))\n```\n\nIt seems like this shouldn't be a novel desire, but I'm not seeing a great path forward... #rustlang",
"sig": "9c41bb09d4e14172f8bd4df4b9b82e2bd1691dd62a6887a0109b1d0d66050a03fa1b756111723f1f187c87f169a94df277baabbfad46bf715a533e3e5c42354f"
}