concatenate strings differently

This commit is contained in:
Florian Stecker 2024-08-25 13:54:06 -04:00
parent 1153385609
commit a414d89859

View File

@ -1,6 +1,7 @@
use std::env; use std::env;
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use std::iter::once;
fn main() { fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap(); let out_dir = env::var_os("OUT_DIR").unwrap();
@ -41,7 +42,11 @@ fn main() {
fs::write( fs::write(
&dest_path, &dest_path,
"vec![".to_string() + &lines.iter().map(|x|x.as_str()).collect::<String>() + "]" once("vec![")
.chain(lines.iter()
.map(String::as_str)
.chain(once("]")))
.collect::<String>()
).unwrap(); ).unwrap();
println!("cargo::rerun-if-changed=build.rs"); println!("cargo::rerun-if-changed=build.rs");