Repository: diesel-rs/diesel
File: diesel_cli/src/migrations/mod.rs (Rust)

Code before:
/// Opens the .diesel_lock file inside the migrations folder
/// Creates the file if it does not exist
/// A lock can be acquired on this file to make sure we don't have multiple instances of diesel
/// doing migration work
/// See [run_migration_command]::generate for an example
fn migration_folder_lock(dir: PathBuf) -> Result<File, crate::errors::Error> {
    let path = dir.join(".diesel_lock");
    match File::create_new(&path) {
        Ok(file) => Ok(file),
        Err(err) => {
            if matches!(err.kind(), io::ErrorKind::AlreadyExists) {
                File::open(&path).map_err(|err| crate::errors::Error::IoError(err, Some(path)))
            } else {
                Err(crate::errors::Error::IoError(err, Some(path)))
            }
        }
    }
}

fn create_migration_dir<'a>(
    migrations_dir: PathBuf,
    migration_name: &str,
    version: Box<dyn Display + 'a>,
    explicit_version: bool,
) -> Result<PathBuf, crate::errors::Error> {
    const MAX_MIGRATIONS_PER_SEC: u16 = 0xFFFF;
    fn is_duplicate_version(full_version: &str, migration_folders: &Vec<PathBuf>) -> bool {
        for folder in migration_folders {
            if folder.to_string_lossy().starts_with(full_version) {
                return true;
            }
        }
        false
    }

    fn create(
        migrations_dir: &Path,
        version: &str,
        migration_name: &str,
    ) -> Result<PathBuf, crate::errors::Error> {
        let versioned_name = format!("{version}_{migration_name}");
        let path = migrations_dir.join(versioned_name);

        fs::create_dir(&path)
            .map_err(|e| crate::errors::Error::IoError(e, Some(path.to_path_buf())))?;
        Ok(path.to_path_buf())
    }

    let migration_folders: Vec<PathBuf> = migrations_dir
        .read_dir()
        .map_err(|err| crate::errors::Error::IoError(err, Some(migrations_dir.clone())))?

Review comment (suggestion):
Rather use 
```suggestion
    const MAX_MIGRATIONS_PER_SEC: u16 = u16::MAX;
```

Code after:
}

/// Opens the .diesel_lock file inside the migrations folder
/// Creates the file if it does not exist
/// A lock can be acquired on this file to make sure we don't have multiple instances of diesel
/// doing migration work
/// See [run_migration_command]::generate for an example
fn migration_folder_lock(dir: PathBuf) -> Result<File, crate::errors::Error> {
    let path = dir.join(".diesel_lock");
    match File::create_new(&path) {
        Ok(file) => Ok(file),
        Err(err) => {
            if matches!(err.kind(), io::ErrorKind::AlreadyExists) {
                File::open(&path).map_err(|err| crate::errors::Error::IoError(err, Some(path)))
            } else {
                Err(crate::errors::Error::IoError(err, Some(path)))
            }
        }
    }
}

fn create_migration_dir<'a>(
    migrations_dir: PathBuf,
    migration_name: &str,
    version: Box<dyn Display + 'a>,
    explicit_version: bool,
) -> Result<PathBuf, crate::errors::Error> {
    const MAX_MIGRATIONS_PER_SEC: u16 = u16::MAX;
    fn is_duplicate_version(full_version: &str, migration_folders: &Vec<PathBuf>) -> bool {
        for folder in migration_folders {
            if folder.to_string_lossy().starts_with(full_version) {
                return true;
            }
        }
        false
    }

    fn create(
        migrations_dir: &Path,
        version: &str,
        migration_name: &str,
    ) -> Result<PathBuf, crate::errors::Error> {
        let versioned_name = format!("{version}_{migration_name}");
        let path = migrations_dir.join(versioned_name);

        fs::create_dir(&path)
            .map_err(|e| crate::errors::Error::IoError(e, Some(path.to_path_buf())))?;
        Ok(path.to_path_buf())
    }

    let migration_folders: Vec<PathBuf> = migrations_dir