datrs / random-access-disk

Continuously read/write to disk using random offsets and lengths .
Apache License 2.0
27 stars 13 forks source link

Make `open`/`create`/`builder` accept `&PathBuf` and others #49

Closed DrSensor closed 9 months ago

DrSensor commented 9 months ago

Choose one: is this a 🐛 bug fix, a 🙋 feature, or a 🔦 documentation change? 🙋 feature

Checklist

Context

I'm building lsp-proxy and happen to found this crate (thankyou), and this has been bugging me

async fn did_open(&self, params: DidOpenTextDocumentParams) {
  let path = Path::new(params.text_document.uri.path());
  let file = RandomAccess::open(path.clone().into());
  // using `path` for something else
}

This change avoid the need for clone() by using &path. It also mirror to std::fs::File::open<P: AsRef<Path>>(path: P).

Semver Changes

3.1.0

ttiurani commented 9 months ago

Thanks for this, this is an obvious improvement! I quickly tested compilation with downstream projects too, and doesn't seem to cause any issues.

I'll merge and release 3.0.1 right away so I don't forget about it.