Simplify pool size parsing
@@ -59,8 +59,9 @@ pub struct ConnectionPool {
impl ConnectionPool {
pub fn new() -> Self {
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
- let max_size = env::var("DB_POOL_SIZE").unwrap_or_else(|_| "10".to_string());
- let max_size = max_size.parse().expect("DB_POOL_SIZE must be integer");
+ let max_size = env::var("DB_POOL_SIZE")
+ .map(|size| size.parse().expect("DB_POOL_SIZE must be integer"))
+ .unwrap_or(10);
let manager = ConnectionManager::<RecoverableConnection<PgConnection>>::new(database_url);
let pool = Pool::builder()
.max_size(max_size)
