summaryrefslogtreecommitdiff
path: root/gen-dev-cargo-toml/src/main.rs
diff options
context:
space:
mode:
authorMo <76752051+mo8it@users.noreply.github.com>2024-04-18 13:02:35 +0200
committerGitHub <noreply@github.com>2024-04-18 13:02:35 +0200
commit819dea250034a5658d0fe3306f6c35fc49961e17 (patch)
tree122060cdc0ef3f81d367e0afc7b0e3e9d29d33ee /gen-dev-cargo-toml/src/main.rs
parentc613b70363c60c6f4305d09c7394c96cdc6b69e4 (diff)
parent01e6732e4d920d9a1859e05fa28382e4307571af (diff)
Merge pull request #1949 from rust-lang/third-party-exercises
Support for third-party exercises
Diffstat (limited to 'gen-dev-cargo-toml/src/main.rs')
-rw-r--r--gen-dev-cargo-toml/src/main.rs68
1 files changed, 0 insertions, 68 deletions
diff --git a/gen-dev-cargo-toml/src/main.rs b/gen-dev-cargo-toml/src/main.rs
deleted file mode 100644
index 43b4ebd..0000000
--- a/gen-dev-cargo-toml/src/main.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Generates `dev/Cargo.toml` such that it is synced with `info.toml`.
-// `dev/Cargo.toml` is a hack to allow using `cargo run` to test `rustlings`
-// during development.
-
-use anyhow::{bail, Context, Result};
-use serde::Deserialize;
-use std::{
- fs::{self, create_dir},
- io::ErrorKind,
-};
-
-#[derive(Deserialize)]
-struct ExerciseInfo {
- name: String,
- dir: Option<String>,
-}
-
-#[derive(Deserialize)]
-struct InfoFile {
- exercises: Vec<ExerciseInfo>,
-}
-
-fn main() -> Result<()> {
- let exercise_infos = toml_edit::de::from_str::<InfoFile>(
- &fs::read_to_string("info.toml").context("Failed to read `info.toml`")?,
- )
- .context("Failed to deserialize `info.toml`")?
- .exercises;
-
- let mut buf = Vec::with_capacity(1 << 14);
-
- buf.extend_from_slice(
- b"# This file is a hack to allow using `cargo run` to test `rustlings` during development.
-# You shouldn't edit it manually. It is created and updated by running `cargo run -p gen-dev-cargo-toml`.
-
-bin = [\n",
- );
-
- for exercise_info in exercise_infos {
- buf.extend_from_slice(b" { name = \"");
- buf.extend_from_slice(exercise_info.name.as_bytes());
- buf.extend_from_slice(b"\", path = \"../exercises/");
- if let Some(dir) = &exercise_info.dir {
- buf.extend_from_slice(dir.as_bytes());
- buf.push(b'/');
- }
- buf.extend_from_slice(exercise_info.name.as_bytes());
- buf.extend_from_slice(b".rs\" },\n");
- }
-
- buf.extend_from_slice(
- br#"]
-
-[package]
-name = "rustlings-dev"
-edition = "2021"
-publish = false
-"#,
- );
-
- if let Err(e) = create_dir("dev") {
- if e.kind() != ErrorKind::AlreadyExists {
- bail!("Failed to create the `dev` directory: {e}");
- }
- }
-
- fs::write("dev/Cargo.toml", buf).context("Failed to write `dev/Cargo.toml`")
-}