Replace all uses and implementations of new() with default()

This commit is contained in:
Juno Takano 2026-01-05 13:16:46 -03:00
commit 6b739d93c2
15 changed files with 100 additions and 84 deletions

View file

@ -55,7 +55,7 @@ impl std::fmt::Display for Anchor {
None => "<unknown>",
};
let mut tail = String::new();
let mut tail = String::default();
if self.leading {
tail.push_str(" [Leading]");

View file

@ -122,7 +122,7 @@ impl std::fmt::Display for Header {
let display_dom_id = match self.dom_id {
Some(ref dom_id) => format!(" DOM ID {dom_id}"),
None => String::new(),
None => String::default(),
};
write!(
@ -193,7 +193,7 @@ mod tests {
#[test]
fn make_id() {
let mut map: HashMap<String, Vec<String>> = HashMap::new();
let mut map: HashMap<String, Vec<String>> = HashMap::default();
let id = Header::make_id(
&Config::default(),
&Lexeme::new("##", "Title"),
@ -204,33 +204,33 @@ mod tests {
#[test]
fn ascii_ids_set() {
let mut config = Config::new();
let mut config = Config::default();
config.ascii_dom_ids = true;
let id = Header::make_id(
&config,
&Lexeme::new("##", "駄目!"),
&mut HashMap::new(),
&mut HashMap::default(),
);
assert_eq!(id, "h");
}
#[test]
fn ascii_ids_unset() {
let mut config = Config::new();
let mut config = Config::default();
config.ascii_dom_ids = false;
let id = Header::make_id(
&config,
&Lexeme::new("##", "駄目!"),
&mut HashMap::new(),
&mut HashMap::default(),
);
assert_eq!(id, "駄目!");
}
#[test]
fn id_deduplication() {
let mut map: HashMap<String, Vec<String>> = HashMap::new();
let mut map: HashMap<String, Vec<String>> = HashMap::default();
let config = Config::default();
let id =
Header::make_id(&config, &Lexeme::new("##", "UVrcCUjoQ"), &mut map);