Problem
The current API requires callers to create two separate ExtensionRegistry instances — one for parsing and one for formatting — even though they register the same extensions. This is because Parser::with_extension_registry consumes the registry by value, making it unavailable for the subsequent format_with_registry call.
Example invocation:
let mut parse_registry = ExtensionRegistry::new();
parse_registry.register_enhancement::<ReadRelEnhancementWrapper>().unwrap();
let mut format_registry = ExtensionRegistry::new();
format_registry.register_enhancement::<ReadRelEnhancementWrapper>().unwrap();
let plan = Parser::new()
.with_extension_registry(parse_registry)
.parse_plan(input)?;
let (output, errors) = format_with_registry(&plan, &opts, &format_registry);
Proposed fix
Either:
- Have
Parser::with_extension_registry take &ExtensionRegistry (or Arc<ExtensionRegistry>) instead of consuming it, so callers can reuse the same registry for formatting, or
- Return the registry from the parser after parsing so it can be passed to the formatter.
This would let callers set up extensions once and use the same registry for both parsing and formatting.
Problem
The current API requires callers to create two separate
ExtensionRegistryinstances — one for parsing and one for formatting — even though they register the same extensions. This is becauseParser::with_extension_registryconsumes the registry by value, making it unavailable for the subsequentformat_with_registrycall.Example invocation:
Proposed fix
Either:
Parser::with_extension_registrytake&ExtensionRegistry(orArc<ExtensionRegistry>) instead of consuming it, so callers can reuse the same registry for formatting, orThis would let callers set up extensions once and use the same registry for both parsing and formatting.