Skip to content

Replace SCOPE_REPO with a more ergonomic and less coupled API #626

@stefanobaghino

Description

@stefanobaghino

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:

  1. Converting scope atoms to CSS class names
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions