Skip to content

Commit a4be484

Browse files
authored
Merge pull request #279 from dralley/master
Add a from_slice() function like other serde datatype libraries
2 parents 2032228 + 0661a31 commit a4be484

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/de/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ pub struct Deserializer<R: BufRead> {
130130
has_value_field: bool,
131131
}
132132

133-
/// Deserialize a xml string
133+
/// Deserialize an instance of type T from a string of XML text.
134134
pub fn from_str<T: DeserializeOwned>(s: &str) -> Result<T, DeError> {
135135
from_reader(s.as_bytes())
136136
}
137137

138+
/// Deserialize an instance of type T from bytes of XML text.
139+
pub fn from_slice<T: DeserializeOwned>(b: &[u8]) -> Result<T, DeError> {
140+
from_reader(b)
141+
}
142+
138143
/// Deserialize from a reader
139144
pub fn from_reader<R: BufRead, T: DeserializeOwned>(reader: R) -> Result<T, DeError> {
140145
let mut de = Deserializer::from_reader(reader);

0 commit comments

Comments
 (0)