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

Don't unnecessarily restrict create_element to borrowed names #722

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ to get an offset of the error position. For `SyntaxError`s the range
- [#362]: Added `BytesCData::minimal_escape()` which escapes only `&` and `<`.
- [#362]: Added `Serializer::set_quote_level()` which allow to set desired level of escaping.
- [#705]: Added `NsReader::prefixes()` to list all the prefixes currently declared.
- [#629]: Added a default case to `impl_deserialize_for_internally_tagged_enum` macro so that it can handle every attribute that does not match existing cases within an enum variant.
- [#629]: Added a default case to `impl_deserialize_for_internally_tagged_enum` macro so that
it can handle every attribute that does not match existing cases within an enum variant.
- [#722]: Allow to pass owned strings to `Writer::create_element`. This is breaking change!

### Bug Fixes

Expand Down Expand Up @@ -74,6 +76,7 @@ to get an offset of the error position. For `SyntaxError`s the range
[#689]: https://github.com/tafia/quick-xml/pull/689
[#704]: https://github.com/tafia/quick-xml/pull/704
[#705]: https://github.com/tafia/quick-xml/pull/705
[#722]: https://github.com/tafia/quick-xml/pull/722
[#738]: https://github.com/tafia/quick-xml/pull/738


Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/structured_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn fuzz_round_trip(driver: Driver) -> quick_xml::Result<()> {
attributes,
} => {
let element_writer = writer
.create_element(&name)
.create_element(name)
.with_attributes(attributes.into_iter().copied());
use ElementWriterFunc::*;
match func {
Expand Down
7 changes: 4 additions & 3 deletions src/writer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Contains high-level interface for an events-based XML emitter.

use std::borrow::Cow;
use std::io::Write;
use std::result::Result as StdResult;

Expand Down Expand Up @@ -143,13 +144,13 @@ impl<W> Writer<W> {
/// # }
/// ```
#[must_use]
pub fn create_element<'a, N>(&'a mut self, name: &'a N) -> ElementWriter<W>
pub fn create_element<'a, N>(&'a mut self, name: N) -> ElementWriter<W>
where
N: 'a + AsRef<str> + ?Sized,
N: Into<Cow<'a, str>>,
{
ElementWriter {
writer: self,
start_tag: BytesStart::new(name.as_ref()),
start_tag: BytesStart::new(name),
}
}
}
Expand Down