-
Notifications
You must be signed in to change notification settings - Fork 236
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
Make attribute creation more uniform #413
Conversation
3566ac9
to
ce6493d
Compare
See question: #410 (comment) |
src/events/attributes.rs
Outdated
/// # use pretty_assertions::assert_eq; | ||
/// use quick_xml::events::attributes::Attribute; | ||
/// | ||
/// let features = Attribute::new("features".as_bytes(), "Bells & whistles".as_bytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this looks better:
/// let features = Attribute::new("features".as_bytes(), "Bells & whistles".as_bytes()); | |
/// let features = Attribute::new(b"features", b"Bells & whistles"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of this is [u8; <len>]
rather than &[u8]
, so you have to do a bit extra (e.g. as_ref()
, and at that point it's not really cleaner anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only when you apply that suggestion to the tuple, because (b"...", b"...")
will have a type ([u8; <len1>], [u8; <len2>])
. Using byte literals with from_*
methods is compiled, I checked
2f61970
to
eba1900
Compare
@@ -40,6 +42,9 @@ | |||
- [#363]: Do not generate empty `Event::Text` events | |||
- [#412]: Fix using incorrect encoding if `read_to_end` family of methods or `read_text` | |||
method not found a corresponding end tag and reader has non-UTF-8 encoding | |||
- [#413]: `Attribute::from((&[u8], &[u8]))` was made consistent with `Attribute::from((&str, &str))` | |||
in that both will now escape the value. WARNING: if you were passing escaped values via this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to draw more attention to this but it is a somewhat consequential change and users won't get a compile error.
@Mingun I think it makes sense, now, to make the members of Also, do you forsee any reason for the key parameter type to be |
Codecov Report
@@ Coverage Diff @@
## master #413 +/- ##
==========================================
- Coverage 49.58% 49.55% -0.03%
==========================================
Files 22 22
Lines 13935 13953 +18
==========================================
+ Hits 6909 6915 +6
- Misses 7026 7038 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
With private fields it will be impossible to use
Oh, yees... I totally forget, that I introduced |
Well if this is the goal, |
eba1900
to
6b34514
Compare
This PR isn't relevant anymore. |
closes #410