-
Notifications
You must be signed in to change notification settings - Fork 242
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
Add a structure to facilitate .as_str()/.as_bytes() #4
Comments
LGTM! |
I tried that, but it turned out to be too verbose and complicated. I went a different route: use only [u8] for name() and content() methods, and use an AsStr trait that implements as_str() for [u8]. Not sure if the trait is worth to have or not. Let me know what you think: matt2xu@44a245b |
I don't know how useful is the |
The content method is useful to get the whole element, including attributes, for instance in the writer (there is no longer a different method for writing start elements) and for the Debug impl. Plus it seems more natural to get the content of a Text or Comment Event rather than their name, it makes the intent of the code clearer in my opinion. |
I think |
Sure! |
closed by #6 |
For people having compilation issue, #6 breaks existing code. To fix you'll need to:
|
Fix attribute parsing and provide information about attribute shapes
At the moment, Element has two methods as_bytes() and as_str() to allow access to raw bytes or conversion to UTF-8 strings. Also, Element has no way to access the all contents (from start to end) as either raw or str, only as String (which is incidentally why the writer cannot use write_wrapped_str for start elements). Attributes, on the other hand, iterates over raw keys with converted strings. Maybe we could introduce a "Text" structure or something similar, that:
Not sure if Text is a good name, but you get the idea :-)
The text was updated successfully, but these errors were encountered: