1.8 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| global-style-tag-registry | api | formatter | 20260520 | Read the shared global style tag registry used by formatters without local tag overrides. |
|
Global-style-tag-registry
Read the shared global StyleTagRegistry. This helper is useful when code wants to inspect or reuse the current process-wide formatter tag registry.
Interface
pub fn global_style_tag_registry() -> StyleTagRegistry {
output
StyleTagRegistry- Current shared global style tag registry.
Explanation
Detailed rules explaining key parameters and behaviors
- This helper reads the shared global registry used when a formatter has no local registry override.
- It is useful for inspection, temporary replacement, or restoration workflows.
- Local formatter registries still take priority over the global registry.
How to Use
Here are some specific examples provided.
When Need To Snapshot And Restore Global Tags
When tests or boot code temporarily replace the shared registry:
let previous = global_style_tag_registry()
set_global_style_tag_registry(style_tag_registry().set_tag("accent", fg=Some("#123456")))
set_global_style_tag_registry(previous)
In this example, the current global registry is captured and later restored.
Error Case
e.g.:
-
If a formatter already has local style tags, global tag changes may not affect that formatter.
-
This helper only reads the shared registry; it does not mutate it.
Notes
-
Use
set_global_style_tag_registry(...)orreset_global_style_tag_registry()for mutation. -
Global registry changes should be made carefully because they affect subsequent formatting without local overrides.