Only run the selected example, not all of them (#4057)

This commit is contained in:
Dániel Buga 2025-09-05 11:04:04 +02:00 committed by GitHub
parent a84d3cc89f
commit 2a06d38141
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -135,9 +135,10 @@ pub fn examples(workspace: &Path, mut args: ExamplesArgs, action: CargoAction) -
// Sort all examples by name:
examples.sort_by_key(|a| a.binary_name());
let mut filtered = examples.clone();
let mut filtered = vec![];
if let Some(example) = args.example.as_deref() {
filtered.clone_from(&examples);
if !example.eq_ignore_ascii_case("all") {
// Only keep the example the user wants
filtered.retain(|ex| ex.matches_name(example));