Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy way to implement a LineCounter #837

Open
TG-97 opened this issue Jan 13, 2025 · 1 comment
Open

Easy way to implement a LineCounter #837

TG-97 opened this issue Jan 13, 2025 · 1 comment

Comments

@TG-97
Copy link

TG-97 commented Jan 13, 2025

Hello, i am trying to deserialize an XML file using the Event:: functionality. I am looking to implement a linecounter for better error messages. Is there any smooth way to achieve this? All the apporaches i came across yet didn't really work for me. I am trying to avoid having to read the file "line-by-line" and simply counting the lines. My current apporach handles the file by jumping from Event to Event. My attempts to just count the "\n,\r,\r\n"-text events did not really result in a number close to how my file actually looked.
Any ideas are appreciated!

@Mingun
Copy link
Collaborator

Mingun commented Jan 13, 2025

Yes, you can find an example in the documentation of the Reader::into_inner method. The same approach should be possible to implement using get_ref or get_mut methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants