how best to skip comments?

Aperta
#460 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Start by reading the Reader event APIs and the comment handling paths in the repository; the issue does not name files or tests. Compare buffered and unbuffered reading to identify a pattern for skipping comment events, then check whether the approach preserves the reader’s input and buffer constraints. Done means providing a workable way to ignore comments during buffered reading.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement help wanted

I'm looking at porting some applications from xml-rs to quick-xml, and one of the blockers I've hit is that quick_xml doesn't have a way to quickly strip all comments (à la xml-rs's ParserConfig::ignore_comments(true)).

A wrapper function like

fn read_event<'a, 'b, R: BufRead>(
    reader: &'a mut Reader<R>,
    buf: &'b mut Vec<u8>,
) -> Result<Event<'b>> {
    loop {
        let event = reader.read_event(buf)?;
        if !matches!(event, Event::Comment(_)) {
            return Ok(event);
        }
    }
}

seems appealing but of course doesn't work because of our friend

`*buf` was mutably borrowed here in the previous iteration of the loop

Switching to read_event_unbuffered and requiring the input to be &[u8] works but isn't ideal.

Are there any good patterns for ignoring comments?

Lingua principale
Rust
Stelle
1.6k
Fork
299
Merge medio
2g 4h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tafia/quick-xml

Tutte le issue di tafia/quick-xml

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.