Skip to content
Open
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: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

### New Features

- [#1010]: Implement `fmt::Display` on `QName`, `LocalName`, `Prefix` and `Namespace`.
- [#1011]: Implement `PartialEq<&str>` on `LocalName`, `Prefix` and `Namespace`.

### Bug Fixes

- [#1007]: Remove error-prone implementations of `Hash`, `PartialOrd`, and `Ord` from all
Expand All @@ -31,6 +34,8 @@
[#1007]: https://github.com/tafia/quick-xml/pull/1007
[#1009]: https://github.com/tafia/quick-xml/pull/1009

[#1010]: https://github.com/tafia/quick-xml/pull/1010
[#1011]: https://github.com/tafia/quick-xml/pull/1011

## 0.42.0 -- 2026-08-22

Expand Down
46 changes: 44 additions & 2 deletions src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ impl<'a> AsRef<str> for LocalName<'a> {
}
}

impl PartialEq<&str> for LocalName<'_> {
#[inline]
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}

impl PartialEq<LocalName<'_>> for &str {
#[inline]
fn eq(&self, other: &LocalName<'_>) -> bool {
*self == other.0
}
}

impl<'a> From<QName<'a>> for LocalName<'a> {
/// Creates `LocalName` from a [`QName`]
///
Expand Down Expand Up @@ -337,6 +351,20 @@ impl<'a> AsRef<str> for Prefix<'a> {
}
}

impl PartialEq<&str> for Prefix<'_> {
#[inline]
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}

impl PartialEq<Prefix<'_>> for &str {
#[inline]
fn eq(&self, other: &Prefix<'_>) -> bool {
*self == other.0
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////

/// A namespace prefix declaration, `xmlns` or `xmlns:<name>`, as defined in
Expand Down Expand Up @@ -421,6 +449,20 @@ impl<'a> AsRef<str> for Namespace<'a> {
}
}

impl PartialEq<&str> for Namespace<'_> {
#[inline]
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}

impl PartialEq<Namespace<'_>> for &str {
#[inline]
fn eq(&self, other: &Namespace<'_>) -> bool {
*self == other.0
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////

/// Result of [prefix] resolution which creates by [`NamespaceResolver::resolve`],
Expand Down Expand Up @@ -965,11 +1007,11 @@ impl NamespaceResolver {
/// match reader.resolver().resolve_event(event) {
/// (Bound(Namespace("www.xxxx")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag1").into());
/// assert_eq!(e.local_name(), "tag1");
/// }
/// (Bound(Namespace("www.yyyy")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag2").into());
/// assert_eq!(e.local_name(), "tag2");
/// }
/// (_, Event::Start(_)) => unreachable!(),
///
Expand Down
4 changes: 2 additions & 2 deletions src/reader/async_tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,11 @@ impl<R: AsyncBufRead + Unpin> NsReader<R> {
/// match reader.read_resolved_event_into_async(&mut buf).await.unwrap() {
/// (Bound(Namespace("www.xxxx")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag1").into());
/// assert_eq!(e.local_name(), "tag1");
/// }
/// (Bound(Namespace("www.yyyy")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag2").into());
/// assert_eq!(e.local_name(), "tag2");
/// }
/// (_, Event::Start(_)) => unreachable!(),
///
Expand Down
8 changes: 4 additions & 4 deletions src/reader/ns_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ impl<R: BufRead> NsReader<R> {
/// match reader.read_resolved_event_into(&mut buf).unwrap() {
/// (Bound(Namespace("www.xxxx")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag1").into());
/// assert_eq!(e.local_name(), "tag1");
/// }
/// (Bound(Namespace("www.yyyy")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag2").into());
/// assert_eq!(e.local_name(), "tag2");
/// }
/// (_, Event::Start(_)) => unreachable!(),
///
Expand Down Expand Up @@ -555,11 +555,11 @@ impl<'i> NsReader<&'i [u8]> {
/// match reader.read_resolved_event().unwrap() {
/// (Bound(Namespace("www.xxxx")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag1").into());
/// assert_eq!(e.local_name(), "tag1");
/// }
/// (Bound(Namespace("www.yyyy")), Event::Start(e)) => {
/// count += 1;
/// assert_eq!(e.local_name(), QName("tag2").into());
/// assert_eq!(e.local_name(), "tag2");
/// }
/// (_, Event::Start(_)) => unreachable!(),
///
Expand Down
Loading