1
Fork 0

Use strip_{prefix|suffix} instead of {starts|ends}_with+indexing

This commit is contained in:
Yotam Ofek 2025-03-16 15:54:04 +00:00
parent 8b87fefd76
commit a3e4dff183
7 changed files with 20 additions and 21 deletions

View file

@ -1538,8 +1538,13 @@ fn print_native_static_libs(
}
let stem = path.file_stem().unwrap().to_str().unwrap();
// Convert library file-stem into a cc -l argument.
let prefix = if stem.starts_with("lib") && !sess.target.is_like_windows { 3 } else { 0 };
let lib = &stem[prefix..];
let lib = if let Some(lib) = stem.strip_prefix("lib")
&& !sess.target.is_like_windows
{
lib
} else {
stem
};
let path = parent.unwrap_or_else(|| Path::new(""));
if sess.target.is_like_msvc {
// When producing a dll, the MSVC linker may not actually emit a