Skip to content

Commit 6588d38

Browse files
committed
Use BytesText::from_*_str instead of BytesText::from_* whenever possible
1 parent d34b779 commit 6588d38

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/de/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ mod tests {
14051405
br#"item name="hello" source="world.rs""#,
14061406
4
14071407
)),
1408-
Text(BytesText::from_escaped(b"Some text".as_ref())),
1408+
Text(BytesText::from_escaped_str("Some text")),
14091409
End(BytesEnd::borrowed(b"item")),
14101410
Start(BytesStart::borrowed(b"item2", 5)),
14111411
End(BytesEnd::borrowed(b"item2")),

src/reader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ mod test {
25632563

25642564
assert_eq!(
25652565
reader.read_event_impl($buf).unwrap(),
2566-
Event::StartText(BytesText::from_escaped(b"bom".as_ref()).into())
2566+
Event::StartText(BytesText::from_escaped_str("bom").into())
25672567
);
25682568
}
25692569

@@ -2583,7 +2583,7 @@ mod test {
25832583

25842584
assert_eq!(
25852585
reader.read_event_impl($buf).unwrap(),
2586-
Event::DocType(BytesText::from_escaped(b"x".as_ref()))
2586+
Event::DocType(BytesText::from_escaped_str("x"))
25872587
);
25882588
}
25892589

@@ -2593,7 +2593,7 @@ mod test {
25932593

25942594
assert_eq!(
25952595
reader.read_event_impl($buf).unwrap(),
2596-
Event::PI(BytesText::from_escaped(b"xml-stylesheet".as_ref()))
2596+
Event::PI(BytesText::from_escaped_str("xml-stylesheet"))
25972597
);
25982598
}
25992599

@@ -2642,7 +2642,7 @@ mod test {
26422642

26432643
assert_eq!(
26442644
reader.read_event_impl($buf).unwrap(),
2645-
Event::Text(BytesText::from_escaped(b"text".as_ref()))
2645+
Event::Text(BytesText::from_escaped_str("text"))
26462646
);
26472647
}
26482648

@@ -2662,7 +2662,7 @@ mod test {
26622662

26632663
assert_eq!(
26642664
reader.read_event_impl($buf).unwrap(),
2665-
Event::Comment(BytesText::from_escaped(b"".as_ref()))
2665+
Event::Comment(BytesText::from_escaped_str(""))
26662666
);
26672667
}
26682668

src/se/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ impl<'r, W: Write> Serializer<'r, W> {
100100
value: P,
101101
escaped: bool,
102102
) -> Result<(), DeError> {
103-
let value = value.to_string().into_bytes();
103+
let value = value.to_string();
104104
let event = if escaped {
105-
BytesText::from_escaped(value)
105+
BytesText::from_escaped_str(&value)
106106
} else {
107-
BytesText::from_plain(&value)
107+
BytesText::from_plain_str(&value)
108108
};
109109
self.writer.write_event(Event::Text(event))?;
110110
Ok(())

src/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ mod indentation {
422422
let start = BytesStart::borrowed_name(name)
423423
.with_attributes(vec![("attr1", "value1"), ("attr2", "value2")].into_iter());
424424
let end = BytesEnd::borrowed(name);
425-
let text = BytesText::from_plain(b"text");
425+
let text = BytesText::from_plain_str("text");
426426

427427
writer
428428
.write_event(Event::Start(start))
@@ -449,7 +449,7 @@ mod indentation {
449449
let start = BytesStart::borrowed_name(name)
450450
.with_attributes(vec![("attr1", "value1"), ("attr2", "value2")].into_iter());
451451
let end = BytesEnd::borrowed(name);
452-
let text = BytesText::from_plain(b"text");
452+
let text = BytesText::from_plain_str("text");
453453
let inner = BytesStart::borrowed_name(b"inner");
454454

455455
writer

0 commit comments

Comments
 (0)