Opening the unnamed database is fallible as it uses the same API as the named ones. As the unnamed database always exists, there is no reason to make creating the unnamed database possible.
let rtxn = env.read_txn()?;
// Opening the unnamed database is infallible.
let main = env.open_database(&rtxn, None)?.expect("infallible, always exists");
let rtxn = env.read_txn()?;
// The unnamed database always exists, no reason to create it.
let main = env.create_database(&mut wtxn, None)?;
We could simplify the API by removing the Option<&str> from both methods and giving access to the unnamed database from another API endpoint like Env::unnamed_database(&self).
Opening the unnamed database is fallible as it uses the same API as the named ones. As the unnamed database always exists, there is no reason to make creating the unnamed database possible.
We could simplify the API by removing the
Option<&str>
from both methods and giving access to the unnamed database from another API endpoint likeEnv::unnamed_database(&self)
.