1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-09-18 11:31:35 +02:00

Check the exercise name length

This commit is contained in:
mo8it 2024-08-28 00:34:24 +02:00
parent dd52e9cd72
commit c209c874a9

View File

@ -14,7 +14,7 @@ use crate::{
collections::{hash_set_with_capacity, HashSet},
exercise::{RunnableExercise, OUTPUT_CAPACITY},
info_file::{ExerciseInfo, InfoFile},
CURRENT_FORMAT_VERSION,
CURRENT_FORMAT_VERSION, MAX_EXERCISE_NAME_LEN,
};
// Find a char that isn't allowed in the exercise's `name` or `dir`.
@ -59,6 +59,9 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<HashSet<PathBuf>> {
if name.is_empty() {
bail!("Found an empty exercise name in `info.toml`");
}
if name.len() > MAX_EXERCISE_NAME_LEN {
bail!("The length of the exercise name `{name}` is bigger than the maximum {MAX_EXERCISE_NAME_LEN}");
}
if let Some(c) = forbidden_char(name) {
bail!("Char `{c}` in the exercise name `{name}` is not allowed");
}