Background
SCOPE_REPO has been deprecated since 5.3.0 (#575). Several replacement approaches have been proposed:
Problem
All proposals so far still expose locking internals (Mutex, MutexGuard), coupling the public API to the current synchronization strategy. Ideally the replacement should be less coupled to the synchronization primitive and more ergonomic for consumers.
Known use case
wastebin needs per-atom string access from a Scope for:
- Converting scope atoms to CSS class names
- Checking if a scope's atoms match specific strings (e.g. markdown link detection)
syntect's own html.rs (scope_to_classes, scope_to_selector) uses the same pattern internally.
Ideas discussed
Scope::atoms() -> Vec<String> — simple but allocates on hot paths used internally by html.rs (#625 comment)
- Closure-based API like
Scope::with_atoms(|&[&str]| { ... }) — zero-alloc but ergonomically awkward
- Smarter
ClassedHTMLGenerator / hooks into line_tokens_to_classed_spans — would eliminate the need for direct repo access for some users (#625 comment)
Suggestion
I'd suggest adding this to the 6.0.0 milestone since any replacement for SCOPE_REPO will be a breaking change.
References
Background
SCOPE_REPOhas been deprecated since 5.3.0 (#575). Several replacement approaches have been proposed:scope_repo()function returning&'static Mutex<ScopeRepository>lock_global_scope_repo()returningMutexGuard<'static, ScopeRepository>Problem
All proposals so far still expose locking internals (
Mutex,MutexGuard), coupling the public API to the current synchronization strategy. Ideally the replacement should be less coupled to the synchronization primitive and more ergonomic for consumers.Known use case
wastebin needs per-atom string access from a
Scopefor:syntect's own
html.rs(scope_to_classes,scope_to_selector) uses the same pattern internally.Ideas discussed
Scope::atoms() -> Vec<String>— simple but allocates on hot paths used internally byhtml.rs(#625 comment)Scope::with_atoms(|&[&str]| { ... })— zero-alloc but ergonomically awkwardClassedHTMLGenerator/ hooks intoline_tokens_to_classed_spans— would eliminate the need for direct repo access for some users (#625 comment)Suggestion
I'd suggest adding this to the 6.0.0 milestone since any replacement for
SCOPE_REPOwill be a breaking change.References
once_cell#575 — original deprecation discussionscope_repo()proposal by @CosmicHorrorDevlock_global_scope_repo()attempt