mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-17 22:58:08 -05:00
Limit the maximum number of exercises to 999
This commit is contained in:
parent
a675cb5754
commit
990a722852
2 changed files with 6 additions and 1 deletions
|
@ -17,6 +17,7 @@ use crate::{
|
||||||
CURRENT_FORMAT_VERSION,
|
CURRENT_FORMAT_VERSION,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MAX_N_EXERCISES: usize = 999;
|
||||||
const MAX_EXERCISE_NAME_LEN: usize = 32;
|
const MAX_EXERCISE_NAME_LEN: usize = 32;
|
||||||
|
|
||||||
// Find a char that isn't allowed in the exercise's `name` or `dir`.
|
// Find a char that isn't allowed in the exercise's `name` or `dir`.
|
||||||
|
@ -347,6 +348,10 @@ fn check_solutions(
|
||||||
pub fn check(require_solutions: bool) -> Result<()> {
|
pub fn check(require_solutions: bool) -> Result<()> {
|
||||||
let info_file = InfoFile::parse()?;
|
let info_file = InfoFile::parse()?;
|
||||||
|
|
||||||
|
if info_file.exercises.len() > MAX_N_EXERCISES {
|
||||||
|
bail!("The maximum number of exercises is {MAX_N_EXERCISES}");
|
||||||
|
}
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
// A hack to make `cargo run -- dev check` work when developing Rustlings.
|
// A hack to make `cargo run -- dev check` work when developing Rustlings.
|
||||||
check_cargo_toml(&info_file.exercises, "dev/Cargo.toml", b"../")?;
|
check_cargo_toml(&info_file.exercises, "dev/Cargo.toml", b"../")?;
|
||||||
|
|
|
@ -166,7 +166,7 @@ pub fn progress_bar<'a>(
|
||||||
total: u16,
|
total: u16,
|
||||||
term_width: u16,
|
term_width: u16,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
debug_assert!(total < 1000);
|
debug_assert!(total <= 999);
|
||||||
debug_assert!(progress <= total);
|
debug_assert!(progress <= total);
|
||||||
|
|
||||||
const PREFIX: &[u8] = b"Progress: [";
|
const PREFIX: &[u8] = b"Progress: [";
|
||||||
|
|
Loading…
Reference in a new issue