Skip to content

Commit d4434b2

Browse files
committed
refactor: change to_string to the macro
1 parent c2ae021 commit d4434b2

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/write.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,30 @@ pub fn write_string(node: Node, indent: Option<usize>, default_xml_def: Option<b
6464
#[cfg(test)]
6565
mod tests {
6666
use crate::entities::Node;
67+
use crate::f_str;
6768
use crate::write::{write_file, write_node_to_string, write_string};
6869
use std::collections::HashMap;
6970
use std::fs::{read_to_string, remove_file};
7071
fn root_node() -> Node {
7172
let mut attrs = HashMap::new();
72-
attrs.insert("test".to_string(), "test".to_string());
73+
attrs.insert(f_str!("test"), f_str!("test"));
7374
let mut root = Node {
74-
name: "root".to_string(),
75+
name: f_str!("root"),
7576
attrs: attrs.clone(),
7677
children: Vec::new(),
7778
text: None,
7879
};
7980
let mut child = Node {
80-
name: "child".to_string(),
81+
name: f_str!("child"),
8182
attrs,
8283
children: Vec::new(),
8384
text: None,
8485
};
8586
child.children.push(Node {
86-
name: "child".to_string(),
87+
name: f_str!("child"),
8788
attrs: HashMap::new(),
8889
children: Vec::new(),
89-
text: Some("test".to_string()),
90+
text: Some(f_str!("test")),
9091
});
9192
root.children.push(child);
9293
root
@@ -112,12 +113,7 @@ mod tests {
112113
fn test_write_file() {
113114
let root = root_node();
114115
let expected = expected_file();
115-
write_file(
116-
root,
117-
"tests/test_write.xml".to_string(),
118-
Some(4),
119-
Some(true),
120-
);
116+
write_file(root, f_str!("tests/test_write.xml"), Some(4), Some(true));
121117
let file_str = read_to_string("tests/test_write.xml").unwrap();
122118
remove_file("tests/test_write.xml").unwrap();
123119
assert_eq!(file_str, expected);

0 commit comments

Comments
 (0)