RS.CLIPPY.STRING_EXTEND_CHARS

Using `x.extend(s.chars())` where s is a `&str` or `String`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: string_extend_chars. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for the use of .extend(s.chars()) where s is a &str or String.

Why is this bad?

.push_str(s) is clearer

Example

let abc = "abc";
let def = String::from("def");
let mut s = String::new();
s.extend(abc.chars());
s.extend(def.chars());

The correct use would be:

let abc = "abc";
let def = String::from("def");
let mut s = String::new();
s.push_str(abc);
s.push_str(&def);