how best to skip comments?

Đang mở
#460 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
Rust
Star
1.6k
Fork
299
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tafia/quick-xml

Tất cả issue của tafia/quick-xml

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.