aboutsummaryrefslogtreecommitdiff
path: root/src/tagged.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-05-14 16:01:39 +0200
committerHampusM <hampus@hampusmat.com>2023-05-14 16:01:39 +0200
commit0f44f2f36c3fa594e8bf9c0b23b7b8041cc6d13e (patch)
treeed26ee090efa8bc9603bf4e4d2f3538a4aedb3f0 /src/tagged.rs
parent1a405580b30f0b877ca48cd95ca51da9e5723667 (diff)
feat: make the TagStart name function return a string
Diffstat (limited to 'src/tagged.rs')
-rw-r--r--src/tagged.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/tagged.rs b/src/tagged.rs
index 19ae03b..0150697 100644
--- a/src/tagged.rs
+++ b/src/tagged.rs
@@ -26,24 +26,24 @@ impl<'a> TagStart<'a>
}
}
- /// Returns the tag name.
+ /// Returns the name.
+ ///
+ /// # Errors
+ /// Returns `Err` if the name is not valid UTF-8.
+ pub fn name(&self) -> Result<&str, Utf8Error>
+ {
+ std::str::from_utf8(self.name_bytes())
+ }
+
+ /// Returns the name as bytes.
#[must_use]
- pub fn name(&self) -> &[u8]
+ pub fn name_bytes(&self) -> &[u8]
{
let name_length = self.inner.name().as_ref().len();
&self.inner.as_ref()[..name_length]
}
- /// Returns the tag name in UTF-8.
- ///
- /// # Errors
- /// Returns `Err` if the name is not valid UTF-8.
- pub fn name_utf8(&self) -> Result<&str, Utf8Error>
- {
- std::str::from_utf8(self.name())
- }
-
/// Returns the tag attributes.
#[must_use]
pub fn attributes(&'a self) -> AttributeIter<'a>