Skip to content

Commit

Permalink
Implement From<String> and From<Cow<str>> for quick_xml::de::Text
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Oct 20, 2024
1 parent 45a66e5 commit 1920e03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

### New Features

- [#826]: Implement `From<String>` and `From<Cow<str>>` for `quick_xml::de::Text`.

### Bug Fixes

- [#655]: Do not write indent before and after `$text` fields and those `$value` fields
Expand Down
16 changes: 16 additions & 0 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,22 @@ impl<'a> From<&'a str> for Text<'a> {
}
}

impl<'a> From<String> for Text<'a> {
#[inline]
fn from(text: String) -> Self {
Self {
text: Cow::Owned(text),
}
}
}

impl<'a> From<Cow<'a, str>> for Text<'a> {
#[inline]
fn from(text: Cow<'a, str>) -> Self {
Self { text }
}
}

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

/// Simplified event which contains only these variants that used by deserializer
Expand Down

0 comments on commit 1920e03

Please sign in to comment.