summaryrefslogtreecommitdiff
path: root/src/init.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-04 15:44:48 +0200
committermo8it <mo8it@proton.me>2024-04-04 15:44:48 +0200
commit569a68eb73b82040588138b0ba1daabca1a7d415 (patch)
tree22c97919aa7c69f1be94a3902c4beb204a3a7699 /src/init.rs
parent1885ece2dcc63d81d4f439d052bd63c168cc0d90 (diff)
Minify generated Cargo.toml
Diffstat (limited to 'src/init.rs')
-rw-r--r--src/init.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/init.rs b/src/init.rs
index d958c96..b52b613 100644
--- a/src/init.rs
+++ b/src/init.rs
@@ -10,21 +10,25 @@ use crate::{embedded::EMBEDDED_FILES, exercise::Exercise};
fn create_cargo_toml(exercises: &[Exercise]) -> io::Result<()> {
let mut cargo_toml = Vec::with_capacity(1 << 13);
+ cargo_toml.extend_from_slice(b"bin = [\n");
+ for exercise in exercises {
+ cargo_toml.extend_from_slice(b" { name = \"");
+ cargo_toml.extend_from_slice(exercise.name.as_bytes());
+ cargo_toml.extend_from_slice(b"\", path = \"");
+ cargo_toml.extend_from_slice(exercise.path.to_str().unwrap().as_bytes());
+ cargo_toml.extend_from_slice(b"\" },\n");
+ }
+
cargo_toml.extend_from_slice(
- br#"[package]
+ br#"]
+
+[package]
name = "rustlings"
version = "0.0.0"
edition = "2021"
publish = false
"#,
);
- for exercise in exercises {
- cargo_toml.extend_from_slice(b"\n[[bin]]\nname = \"");
- cargo_toml.extend_from_slice(exercise.name.as_bytes());
- cargo_toml.extend_from_slice(b"\"\npath = \"");
- cargo_toml.extend_from_slice(exercise.path.to_str().unwrap().as_bytes());
- cargo_toml.extend_from_slice(b"\"\n");
- }
OpenOptions::new()
.create_new(true)
.write(true)