Skip to content

Commit d66df32

Browse files
Mingundralley
authored andcommitted
Implement From<QName> for BytesStart and BytesEnd
1 parent 65bf651 commit d66df32

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
### New Features
1414

15+
- [#758]: Implemented `From<QName>` for `BytesStart` and `BytesEnd`.
16+
1517
### Bug Fixes
1618

1719
- [#755]: Fix incorrect missing of trimming all-space text events when
@@ -23,6 +25,7 @@
2325

2426
[#650]: https://github.com/tafia/quick-xml/issues/650
2527
[#755]: https://github.com/tafia/quick-xml/pull/755
28+
[#758]: https://github.com/tafia/quick-xml/pull/758
2629

2730

2831
## 0.32.0 -- 2024-06-10

src/events/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ impl<'a> BytesStart<'a> {
163163
}
164164

165165
/// Creates new paired close tag
166+
#[inline]
166167
pub fn to_end(&self) -> BytesEnd {
167-
BytesEnd::wrap(self.name().into_inner().into())
168+
BytesEnd::from(self.name())
168169
}
169170

170171
/// Gets the undecoded raw tag name, as present in the input stream.
@@ -322,6 +323,14 @@ impl<'a> Deref for BytesStart<'a> {
322323
}
323324
}
324325

326+
impl<'a> From<QName<'a>> for BytesStart<'a> {
327+
#[inline]
328+
fn from(name: QName<'a>) -> Self {
329+
let name = name.into_inner();
330+
Self::wrap(name, name.len())
331+
}
332+
}
333+
325334
#[cfg(feature = "arbitrary")]
326335
impl<'a> arbitrary::Arbitrary<'a> for BytesStart<'a> {
327336
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
@@ -673,6 +682,13 @@ impl<'a> Deref for BytesEnd<'a> {
673682
}
674683
}
675684

685+
impl<'a> From<QName<'a>> for BytesEnd<'a> {
686+
#[inline]
687+
fn from(name: QName<'a>) -> Self {
688+
Self::wrap(name.into_inner().into())
689+
}
690+
}
691+
676692
#[cfg(feature = "arbitrary")]
677693
impl<'a> arbitrary::Arbitrary<'a> for BytesEnd<'a> {
678694
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {

0 commit comments

Comments
 (0)