Skip to content

Commit

Permalink
Merge pull request #49 from DrSensor/refactor/as-ref-path
Browse files Browse the repository at this point in the history
Make `open`/`create`/`builder` accept `&PathBuf` and others
  • Loading branch information
ttiurani authored Jan 9, 2024
2 parents 44134ff + 69cfe70 commit bfabf67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ impl RandomAccessDisk {
/// Create a new (auto-sync) instance to storage at `filename`.
#[allow(clippy::new_ret_no_self)]
pub async fn open(
filename: path::PathBuf,
filename: impl AsRef<path::Path>,
) -> Result<RandomAccessDisk, RandomAccessError> {
Self::builder(filename).build().await
}

/// Initialize a builder with storage at `filename`.
pub fn builder(filename: path::PathBuf) -> Builder {
pub fn builder(filename: impl AsRef<path::Path>) -> Builder {
Builder::new(filename)
}
}
Expand Down Expand Up @@ -345,9 +345,9 @@ pub struct Builder {

impl Builder {
/// Create new builder at `path` (with auto-sync true by default).
pub fn new(filename: path::PathBuf) -> Self {
pub fn new(filename: impl AsRef<path::Path>) -> Self {
Self {
filename,
filename: filename.as_ref().into(),
auto_sync: true,
}
}
Expand Down

0 comments on commit bfabf67

Please sign in to comment.